From: Vaibhav Jain <vaibhav@linux.ibm.com> To: qemu-devel@nongnu.org, kvm-ppc@vger.kernel.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, mst@redhat.com, imammedo@redhat.com, xiaoguangrong.eric@gmail.com Cc: ehabkost@redhat.com, aneesh.kumar@linux.ibm.com, groug@kaod.org, shivaprasadbhat@gmail.com, bharata@linux.vnet.ibm.com, Vaibhav Jain <vaibhav@linux.ibm.com> Subject: [PATCH] ppc/spapr: Add support for implement support for H_SCM_HEALTH Date: Mon, 29 Mar 2021 21:52:59 +0530 [thread overview] Message-ID: <20210329162259.536964-1-vaibhav@linux.ibm.com> (raw) Add support for H_SCM_HEALTH hcall described at [1] for spapr nvdimms. This enables guest to detect the 'unarmed' status of a specific spapr nvdimm identified by its DRC and if its unarmed, mark the region backed by the nvdimm as read-only. The patch adds h_scm_health() to handle the H_SCM_HEALTH hcall which returns two 64-bit bitmaps (health bitmap, health bitmap mask) derived from 'struct nvdimm->unarmed' member. Linux kernel side changes to enable handling of 'unarmed' nvdimms for ppc64 are proposed at [2]. References: [1] "Hypercall Op-codes (hcalls)" https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/powerpc/papr_hcalls.rst [2] "powerpc/papr_scm: Mark nvdimm as unarmed if needed during probe" https://lore.kernel.org/linux-nvdimm/20210329113103.476760-1-vaibhav@linux.ibm.com/ Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com> --- hw/ppc/spapr_nvdimm.c | 30 ++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index b46c36917c..e38740036d 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -31,6 +31,13 @@ #include "qemu/range.h" #include "hw/ppc/spapr_numa.h" +/* DIMM health bitmap bitmap indicators */ +/* SCM device is unable to persist memory contents */ +#define PAPR_PMEM_UNARMED (1ULL << (63 - 0)) + +/* Bits status indicators for health bitmap indicating unarmed dimm */ +#define PAPR_PMEM_UNARMED_MASK (PAPR_PMEM_UNARMED) + bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdimm, uint64_t size, Error **errp) { @@ -467,6 +474,28 @@ static target_ulong h_scm_unbind_all(PowerPCCPU *cpu, SpaprMachineState *spapr, return H_SUCCESS; } +static target_ulong h_scm_health(PowerPCCPU *cpu, SpaprMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + uint32_t drc_index = args[0]; + SpaprDrc *drc = spapr_drc_by_index(drc_index); + NVDIMMDevice *nvdimm; + + if (drc && spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PMEM) { + return H_PARAMETER; + } + + nvdimm = NVDIMM(drc->dev); + + /* Check if the nvdimm is unarmed and send its status via health bitmaps */ + args[0] = nvdimm->unarmed ? PAPR_PMEM_UNARMED_MASK : 0; + + /* health bitmap mask same as the health bitmap */ + args[1] = args[0]; + + return H_SUCCESS; +} + static void spapr_scm_register_types(void) { /* qemu/scm specific hcalls */ @@ -475,6 +504,7 @@ static void spapr_scm_register_types(void) spapr_register_hypercall(H_SCM_BIND_MEM, h_scm_bind_mem); spapr_register_hypercall(H_SCM_UNBIND_MEM, h_scm_unbind_mem); spapr_register_hypercall(H_SCM_UNBIND_ALL, h_scm_unbind_all); + spapr_register_hypercall(H_SCM_HEALTH, h_scm_health); } type_init(spapr_scm_register_types) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 47cebaf3ac..18859b9ab2 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -538,8 +538,8 @@ struct SpaprMachineState { #define H_SCM_BIND_MEM 0x3EC #define H_SCM_UNBIND_MEM 0x3F0 #define H_SCM_UNBIND_ALL 0x3FC - -#define MAX_HCALL_OPCODE H_SCM_UNBIND_ALL +#define H_SCM_HEALTH 0x400 +#define MAX_HCALL_OPCODE H_SCM_HEALTH /* The hcalls above are standardized in PAPR and implemented by pHyp * as well. -- 2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Vaibhav Jain <vaibhav@linux.ibm.com> To: qemu-devel@nongnu.org, kvm-ppc@vger.kernel.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, mst@redhat.com, imammedo@redhat.com, xiaoguangrong.eric@gmail.com Cc: ehabkost@redhat.com, aneesh.kumar@linux.ibm.com, groug@kaod.org, shivaprasadbhat@gmail.com, bharata@linux.vnet.ibm.com, Vaibhav Jain <vaibhav@linux.ibm.com> Subject: [PATCH] ppc/spapr: Add support for implement support for H_SCM_HEALTH Date: Mon, 29 Mar 2021 16:34:59 +0000 [thread overview] Message-ID: <20210329162259.536964-1-vaibhav@linux.ibm.com> (raw) Add support for H_SCM_HEALTH hcall described at [1] for spapr nvdimms. This enables guest to detect the 'unarmed' status of a specific spapr nvdimm identified by its DRC and if its unarmed, mark the region backed by the nvdimm as read-only. The patch adds h_scm_health() to handle the H_SCM_HEALTH hcall which returns two 64-bit bitmaps (health bitmap, health bitmap mask) derived from 'struct nvdimm->unarmed' member. Linux kernel side changes to enable handling of 'unarmed' nvdimms for ppc64 are proposed at [2]. References: [1] "Hypercall Op-codes (hcalls)" https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/powerpc/papr_hcalls.rst [2] "powerpc/papr_scm: Mark nvdimm as unarmed if needed during probe" https://lore.kernel.org/linux-nvdimm/20210329113103.476760-1-vaibhav@linux.ibm.com/ Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com> --- hw/ppc/spapr_nvdimm.c | 30 ++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index b46c36917c..e38740036d 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -31,6 +31,13 @@ #include "qemu/range.h" #include "hw/ppc/spapr_numa.h" +/* DIMM health bitmap bitmap indicators */ +/* SCM device is unable to persist memory contents */ +#define PAPR_PMEM_UNARMED (1ULL << (63 - 0)) + +/* Bits status indicators for health bitmap indicating unarmed dimm */ +#define PAPR_PMEM_UNARMED_MASK (PAPR_PMEM_UNARMED) + bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdimm, uint64_t size, Error **errp) { @@ -467,6 +474,28 @@ static target_ulong h_scm_unbind_all(PowerPCCPU *cpu, SpaprMachineState *spapr, return H_SUCCESS; } +static target_ulong h_scm_health(PowerPCCPU *cpu, SpaprMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + uint32_t drc_index = args[0]; + SpaprDrc *drc = spapr_drc_by_index(drc_index); + NVDIMMDevice *nvdimm; + + if (drc && spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PMEM) { + return H_PARAMETER; + } + + nvdimm = NVDIMM(drc->dev); + + /* Check if the nvdimm is unarmed and send its status via health bitmaps */ + args[0] = nvdimm->unarmed ? PAPR_PMEM_UNARMED_MASK : 0; + + /* health bitmap mask same as the health bitmap */ + args[1] = args[0]; + + return H_SUCCESS; +} + static void spapr_scm_register_types(void) { /* qemu/scm specific hcalls */ @@ -475,6 +504,7 @@ static void spapr_scm_register_types(void) spapr_register_hypercall(H_SCM_BIND_MEM, h_scm_bind_mem); spapr_register_hypercall(H_SCM_UNBIND_MEM, h_scm_unbind_mem); spapr_register_hypercall(H_SCM_UNBIND_ALL, h_scm_unbind_all); + spapr_register_hypercall(H_SCM_HEALTH, h_scm_health); } type_init(spapr_scm_register_types) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 47cebaf3ac..18859b9ab2 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -538,8 +538,8 @@ struct SpaprMachineState { #define H_SCM_BIND_MEM 0x3EC #define H_SCM_UNBIND_MEM 0x3F0 #define H_SCM_UNBIND_ALL 0x3FC - -#define MAX_HCALL_OPCODE H_SCM_UNBIND_ALL +#define H_SCM_HEALTH 0x400 +#define MAX_HCALL_OPCODE H_SCM_HEALTH /* The hcalls above are standardized in PAPR and implemented by pHyp * as well. -- 2.30.2
next reply other threads:[~2021-03-29 19:16 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-29 16:22 Vaibhav Jain [this message] 2021-03-29 16:34 ` [PATCH] ppc/spapr: Add support for implement support for H_SCM_HEALTH Vaibhav Jain 2021-03-30 6:38 ` Shivaprasad G Bhat 2021-03-30 6:50 ` Shivaprasad G Bhat 2021-03-30 8:38 ` Vaibhav Jain 2021-03-30 8:50 ` Vaibhav Jain 2021-03-30 14:14 ` Greg Kurz 2021-03-30 14:14 ` Greg Kurz 2021-03-30 17:07 ` Vaibhav Jain 2021-03-30 17:19 ` Vaibhav Jain 2021-03-30 23:49 ` David Gibson 2021-03-30 23:49 ` David Gibson 2021-03-31 3:49 ` Vaibhav Jain 2021-03-31 3:50 ` Vaibhav Jain 2021-03-31 9:15 ` Greg Kurz 2021-03-31 9:15 ` Greg Kurz
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210329162259.536964-1-vaibhav@linux.ibm.com \ --to=vaibhav@linux.ibm.com \ --cc=aneesh.kumar@linux.ibm.com \ --cc=bharata@linux.vnet.ibm.com \ --cc=david@gibson.dropbear.id.au \ --cc=ehabkost@redhat.com \ --cc=groug@kaod.org \ --cc=imammedo@redhat.com \ --cc=kvm-ppc@vger.kernel.org \ --cc=mst@redhat.com \ --cc=qemu-devel@nongnu.org \ --cc=qemu-ppc@nongnu.org \ --cc=shivaprasadbhat@gmail.com \ --cc=xiaoguangrong.eric@gmail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.