From: Sam Bobroff <sam.bobroff@au1.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au
Subject: [Qemu-devel] [RFC PATCH 6/9] spapr: Add h_register_process_table() hypercall
Date: Tue, 7 Feb 2017 13:56:49 +1100 [thread overview]
Message-ID: <fe7cb0c915e6c88f090e7167410165bf0e7d14bc.1486436186.git.sam.bobroff@au1.ibm.com> (raw)
In-Reply-To: <cover.1486436185.git.sam.bobroff@au1.ibm.com>
In-Reply-To: <cover.1486436185.git.sam.bobroff@au1.ibm.com>
Both radix and hash modes require guests to use
h_register_process_table() to set up the MMU. Implement it using the
new KVM ioctl KVM_PPC_CONFIGURE_V3_MMU.
This hypercall is also necessary for fully emulated guests, so it will
need to be reworked to integrate with Suraj's TCG patchset.
---
hw/ppc/spapr_hcall.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr.h | 3 ++-
target/ppc/kvm.c | 12 ++++++++++++
target/ppc/kvm_ppc.h | 1 +
4 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index c9bb6624c4..4de511c386 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1049,6 +1049,50 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,
return H_SUCCESS;
}
+static target_ulong h_register_process_table(PowerPCCPU *cpu,
+ sPAPRMachineState *spapr,
+ target_ulong opcode,
+ target_ulong *args)
+{
+ static target_ulong last_process_table;
+ target_ulong flags = args[0];
+ target_ulong proc_tbl = args[1];
+ target_ulong page_size = args[2];
+ target_ulong table_size = args[3];
+ uint64_t cflags, cproc;
+
+ cflags = (flags & 4) ? KVM_PPC_MMUV3_RADIX : 0;
+ cflags |= (flags & 1) ? KVM_PPC_MMUV3_GTSE : 0;
+ cproc = (flags & 4) ? (1ul << 63) : 0;
+ if (!(flags & 0x10)) {
+ if ((last_process_table & (1ul << 63)) != cproc) {
+ return H_PARAMETER;
+ }
+ cproc = last_process_table;
+ } else if (!(flags & 0x8)) {
+ ; /* do nothing */
+ } else if (flags & 4) {
+ /* radix */
+ if (table_size > 24 || (proc_tbl & 0xfff) || (proc_tbl >> 60)) {
+ return H_PARAMETER;
+ }
+ cproc |= proc_tbl | table_size;
+ } else {
+ /* hash, possibly with process table */
+ if (table_size > 24 || (proc_tbl >> 38) || page_size > 7) {
+ return H_PARAMETER;
+ }
+ cproc = (proc_tbl << 25) | (page_size << 5) | table_size;
+ }
+ last_process_table = cproc;
+ fprintf(stderr, "calling config mmu flags=%lx proctbl=%lx\n",
+ cflags, cproc);
+ if (!kvmppc_configure_v3_mmu(cpu, cflags, cproc)) {
+ return H_HARDWARE;
+ }
+ return H_SUCCESS;
+}
+
static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1];
static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - KVMPPC_HCALL_BASE + 1];
@@ -1136,6 +1180,10 @@ static void hypercall_register_types(void)
/* ibm,client-architecture-support support */
spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support);
+
+ /* Power9 MMU support */
+ spapr_register_hypercall(H_REGISTER_PROCESS_TABLE,
+ h_register_process_table);
}
type_init(hypercall_register_types)
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index bd5bcf70de..92bda0f36d 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -347,7 +347,8 @@ struct sPAPRMachineState {
#define H_XIRR_X 0x2FC
#define H_RANDOM 0x300
#define H_SET_MODE 0x31C
-#define MAX_HCALL_OPCODE H_SET_MODE
+#define H_REGISTER_PROCESS_TABLE 0x37C
+#define MAX_HCALL_OPCODE H_REGISTER_PROCESS_TABLE
/* The hcalls above are standardized in PAPR and implemented by pHyp
* as well.
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 8d6fd1b067..0d1443616c 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -344,6 +344,18 @@ static bool kvm_get_rmmu_info(PowerPCCPU *cpu, struct kvm_ppc_rmmu_info *info)
return false;
}
+bool kvmppc_configure_v3_mmu(PowerPCCPU *cpu, uint64_t flags, uint64_t proc_tbl)
+{
+ CPUState *cs = CPU(cpu);
+ int ret;
+ struct kvm_ppc_mmuv3_cfg cfg;
+
+ cfg.flags = flags;
+ cfg.process_table = proc_tbl;
+ ret = kvm_vm_ioctl(cs->kvm_state, KVM_PPC_CONFIGURE_V3_MMU, &cfg);
+ return ret == 0;
+}
+
static long gethugepagesize(const char *mem_path)
{
struct statfs fs;
diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h
index 1c1b94847c..0b8b77583a 100644
--- a/target/ppc/kvm_ppc.h
+++ b/target/ppc/kvm_ppc.h
@@ -33,6 +33,7 @@ int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
int kvmppc_set_tcr(PowerPCCPU *cpu);
int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
+bool kvmppc_configure_v3_mmu(PowerPCCPU *cpu, uint64_t flags, uint64_t proctbl);
#ifndef CONFIG_USER_ONLY
off_t kvmppc_alloc_rma(void **rma);
bool kvmppc_spapr_use_multitce(void);
--
2.11.0
next prev parent reply other threads:[~2017-02-07 2:58 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 2:56 [Qemu-devel] [RFC PATCH 0/9] ISA 3.00 KVM guest support Sam Bobroff
2017-02-07 2:56 ` [Qemu-devel] [RFC PATCH 1/9] spapr: fix off-by-one error in spapr_ovec_populate_dt() Sam Bobroff
2017-02-07 15:47 ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
2017-02-09 1:53 ` David Gibson
2017-02-07 22:12 ` [Qemu-devel] " Michael Roth
2017-02-07 22:53 ` Sam Bobroff
2017-02-07 2:56 ` [Qemu-devel] [RFC PATCH 2/9] Update headers using update-linux-headers.sh Sam Bobroff
2017-02-07 12:59 ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
2017-02-09 4:53 ` Sam Bobroff
2017-02-09 7:45 ` Thomas Huth
2017-02-09 1:55 ` [Qemu-devel] " David Gibson
2017-02-09 4:54 ` Sam Bobroff
2017-02-07 2:56 ` [Qemu-devel] [RFC PATCH 3/9] spapr: Add ibm, processor-radix-AP-encodings to the device tree Sam Bobroff
2017-02-09 2:14 ` David Gibson
2017-02-09 5:07 ` Sam Bobroff
2017-02-07 2:56 ` [Qemu-devel] [RFC PATCH 4/9] target-ppc: support KVM_CAP_PPC_MMU_RADIX, KVM_CAP_PPC_MMU_HASH_V3 Sam Bobroff
2017-02-09 2:16 ` David Gibson
2017-02-07 2:56 ` [Qemu-devel] [RFC PATCH 5/9] spapr: Only setup HTP if necessary Sam Bobroff
2017-02-09 2:24 ` David Gibson
2017-02-07 2:56 ` Sam Bobroff [this message]
2017-02-09 2:32 ` [Qemu-devel] [RFC PATCH 6/9] spapr: Add h_register_process_table() hypercall David Gibson
2017-02-09 4:16 ` [Qemu-devel] [Qemu-ppc] " Alexey Kardashevskiy
2017-02-07 2:56 ` [Qemu-devel] [RFC PATCH 7/9] spapr: Set ISA 3.00 radix and hash bits in OV5 Sam Bobroff
2017-02-09 2:34 ` David Gibson
2017-02-07 2:56 ` [Qemu-devel] [RFC PATCH 8/9] spapr: Advertise ISA 3.0 MMU features in pa_features Sam Bobroff
2017-02-09 2:42 ` David Gibson
2017-02-07 2:56 ` [Qemu-devel] [RFC PATCH 9/9] spapr: Small cleanup of PPC MMU enums Sam Bobroff
2017-02-09 2:49 ` David Gibson
2017-02-09 2:51 ` [Qemu-devel] [RFC PATCH 0/9] ISA 3.00 KVM guest support David Gibson
2017-02-09 3:21 ` Alexey Kardashevskiy
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=fe7cb0c915e6c88f090e7167410165bf0e7d14bc.1486436186.git.sam.bobroff@au1.ibm.com \
--to=sam.bobroff@au1.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).