From: Greg Kurz <groug@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: abologna@redhat.com, clg@kaod.org, qemu-ppc@nongnu.org,
qemu-devel@nongnu.org, aik@ozlabs.ru
Subject: Re: [Qemu-devel] [PATCH 5/9] spapr: Maximum (HPT) pagesize property
Date: Thu, 21 Jun 2018 11:19:41 +0200 [thread overview]
Message-ID: <20180621111941.5a3f68cc@bahia.lan> (raw)
In-Reply-To: <20180618063606.2513-6-david@gibson.dropbear.id.au>
On Mon, 18 Jun 2018 16:36:02 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> The way the POWER Hash Page Table (HPT) MMU is virtualized by KVM HV means
> that every page that the guest puts in the pagetables must be truly
> physically contiguous, not just GPA-contiguous. In effect this means that
> an HPT guest can't use any pagesizes greater than the host page size used
> to back its memory.
>
> At present we handle this by changing what we advertise to the guest based
> on the backing pagesizes. This is pretty bad, because it means the guest
> sees a different environment depending on what should be host configuration
> details.
>
> As a start on fixing this, we add a new capability parameter to the pseries
> machine type which gives the maximum allowed pagesizes for an HPT guest (as
> a shift).
Maybe you can mention that it is exposed to the user as a genuine pagesize,
not a shift, because it is a friendlier interface.
> For now we just create and validate the parameter without making
> it do anything.
>
> For backwards compatibility, on older machine types we set it to the max
> available page size for the host. For the 3.0 machine type, we fix it to
> 16, the intention being to only allow HPT pagesizes up to 64kiB by default
> in future.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
Reviewed-by: Greg Kurz <groug@kaod.org>
> hw/ppc/spapr.c | 12 +++++++++
> hw/ppc/spapr_caps.c | 56 ++++++++++++++++++++++++++++++++++++++++++
> include/hw/ppc/spapr.h | 4 ++-
> 3 files changed, 71 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 40858d047c..74a76e7e09 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -63,6 +63,7 @@
> #include "hw/virtio/vhost-scsi-common.h"
>
> #include "exec/address-spaces.h"
> +#include "exec/ram_addr.h"
> #include "hw/usb.h"
> #include "qemu/config-file.h"
> #include "qemu/error-report.h"
> @@ -4043,6 +4044,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
> smc->default_caps.caps[SPAPR_CAP_CFPC] = SPAPR_CAP_BROKEN;
> smc->default_caps.caps[SPAPR_CAP_SBBC] = SPAPR_CAP_BROKEN;
> smc->default_caps.caps[SPAPR_CAP_IBS] = SPAPR_CAP_BROKEN;
> + smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] = 16; /* 64kiB */
> spapr_caps_add_properties(smc, &error_abort);
> }
>
> @@ -4126,8 +4128,18 @@ static void spapr_machine_2_12_instance_options(MachineState *machine)
>
> static void spapr_machine_2_12_class_options(MachineClass *mc)
> {
> + sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
> + uint8_t mps;
> +
> spapr_machine_3_0_class_options(mc);
> SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_12);
> +
> + if (kvmppc_hpt_needs_host_contiguous_pages()) {
> + mps = ctz64(qemu_getrampagesize());
> + } else {
> + mps = 34; /* allow everything up to 16GiB, i.e. everything */
> + }
> + smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] = mps;
> }
>
> DEFINE_SPAPR_MACHINE(2_12, "2.12", false);
> diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
> index 68a4243efc..6cdc0c94e7 100644
> --- a/hw/ppc/spapr_caps.c
> +++ b/hw/ppc/spapr_caps.c
> @@ -27,6 +27,7 @@
> #include "qapi/visitor.h"
> #include "sysemu/hw_accel.h"
> #include "target/ppc/cpu.h"
> +#include "target/ppc/mmu-hash64.h"
> #include "cpu-models.h"
> #include "kvm_ppc.h"
>
> @@ -144,6 +145,42 @@ out:
> g_free(val);
> }
>
> +static void spapr_cap_get_pagesize(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> +{
> + sPAPRCapabilityInfo *cap = opaque;
> + sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> + uint8_t val = spapr_get_cap(spapr, cap->index);
> + uint64_t pagesize = (1ULL << val);
> +
> + visit_type_size(v, name, &pagesize, errp);
> +}
> +
> +static void spapr_cap_set_pagesize(Object *obj, Visitor *v, const char *name,
> + void *opaque, Error **errp)
> +{
> + sPAPRCapabilityInfo *cap = opaque;
> + sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> + uint64_t pagesize;
> + uint8_t val;
> + Error *local_err = NULL;
> +
> + visit_type_size(v, name, &pagesize, &local_err);
> + if (local_err) {
> + error_propagate(errp, local_err);
> + return;
> + }
> +
> + if (!is_power_of_2(pagesize)) {
> + error_setg(errp, "cap-%s must be a power of 2", cap->name);
> + return;
> + }
> +
> + val = ctz64(pagesize);
> + spapr->cmd_line_caps[cap->index] = true;
> + spapr->eff.caps[cap->index] = val;
> +}
> +
> static void cap_htm_apply(sPAPRMachineState *spapr, uint8_t val, Error **errp)
> {
> if (!val) {
> @@ -267,6 +304,16 @@ static void cap_safe_indirect_branch_apply(sPAPRMachineState *spapr,
>
> #define VALUE_DESC_TRISTATE " (broken, workaround, fixed)"
>
> +static void cap_hpt_maxpagesize_apply(sPAPRMachineState *spapr,
> + uint8_t val, Error **errp)
> +{
> + if (val < 12) {
> + error_setg(errp, "Require at least 4kiB hpt-max-page-size");
> + } else if (val < 16) {
> + warn_report("Many guests require at least 64kiB hpt-max-page-size");
> + }
> +}
> +
> sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
> [SPAPR_CAP_HTM] = {
> .name = "htm",
> @@ -326,6 +373,15 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
> .possible = &cap_ibs_possible,
> .apply = cap_safe_indirect_branch_apply,
> },
> + [SPAPR_CAP_HPT_MAXPAGESIZE] = {
> + .name = "hpt-max-page-size",
> + .description = "Maximum page size for Hash Page Table guests",
> + .index = SPAPR_CAP_HPT_MAXPAGESIZE,
> + .get = spapr_cap_get_pagesize,
> + .set = spapr_cap_set_pagesize,
> + .type = "int",
> + .apply = cap_hpt_maxpagesize_apply,
> + },
> };
>
> static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index 9dd46a72f6..c97593d032 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -66,8 +66,10 @@ typedef enum {
> #define SPAPR_CAP_SBBC 0x04
> /* Indirect Branch Serialisation */
> #define SPAPR_CAP_IBS 0x05
> +/* HPT Maximum Page Size (encoded as a shift) */
> +#define SPAPR_CAP_HPT_MAXPAGESIZE 0x06
> /* Num Caps */
> -#define SPAPR_CAP_NUM (SPAPR_CAP_IBS + 1)
> +#define SPAPR_CAP_NUM (SPAPR_CAP_HPT_MAXPAGESIZE + 1)
>
> /*
> * Capability Values
next prev parent reply other threads:[~2018-06-21 9:20 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 6:35 [Qemu-devel] [PATCH 0/9] spapr: Clean up pagesize handling David Gibson
2018-06-18 6:35 ` [Qemu-devel] [PATCH 1/9] target/ppc: Allow cpu compatiblity checks based on type, not instance David Gibson
2018-06-18 13:22 ` Greg Kurz
2018-06-21 5:20 ` Cédric Le Goater
2018-06-18 6:35 ` [Qemu-devel] [PATCH 2/9] spapr: Compute effective capability values earlier David Gibson
2018-06-18 13:37 ` Greg Kurz
2018-06-21 5:32 ` Cédric Le Goater
2018-06-18 6:36 ` [Qemu-devel] [PATCH 3/9] spapr: Add cpu_apply hook to capabilities David Gibson
2018-06-18 15:28 ` Greg Kurz
2018-06-21 5:34 ` Cédric Le Goater
2018-06-18 6:36 ` [Qemu-devel] [PATCH 4/9] target/ppc: Add kvmppc_hpt_needs_host_contiguous_pages() helper David Gibson
2018-06-18 15:32 ` Greg Kurz
2018-06-21 5:56 ` Cédric Le Goater
2018-06-21 6:34 ` David Gibson
2018-06-18 6:36 ` [Qemu-devel] [PATCH 5/9] spapr: Maximum (HPT) pagesize property David Gibson
2018-06-19 9:23 ` Cédric Le Goater
2018-06-19 11:22 ` David Gibson
2018-06-21 6:22 ` Cédric Le Goater
2018-06-21 11:00 ` David Gibson
2018-06-21 9:19 ` Greg Kurz [this message]
2018-06-21 11:01 ` David Gibson
2018-06-18 6:36 ` [Qemu-devel] [PATCH 6/9] spapr: Use maximum page size capability to simplify memory backend checking David Gibson
2018-06-21 6:29 ` Cédric Le Goater
2018-06-21 11:06 ` David Gibson
2018-06-21 10:29 ` Greg Kurz
2018-06-21 11:11 ` David Gibson
2018-06-18 6:36 ` [Qemu-devel] [PATCH 7/9] target/ppc: Add ppc_hash64_filter_pagesizes() David Gibson
2018-06-21 6:38 ` Cédric Le Goater
2018-06-21 11:48 ` Greg Kurz
2018-06-18 6:36 ` [Qemu-devel] [PATCH 8/9] spapr: Limit available pagesizes to provide a consistent guest environment David Gibson
2018-06-21 7:01 ` Cédric Le Goater
2018-06-21 11:52 ` David Gibson
2018-06-21 12:50 ` Cédric Le Goater
2018-06-21 13:58 ` David Gibson
2018-06-21 12:24 ` Greg Kurz
2018-06-21 14:01 ` David Gibson
2018-06-21 14:18 ` Greg Kurz
2018-06-18 6:36 ` [Qemu-devel] [PATCH 9/9] spapr: Don't rewrite mmu capabilities in KVM mode David Gibson
2018-06-21 7:53 ` Cédric Le Goater
2018-06-21 12:01 ` David Gibson
2018-06-21 12:51 ` Cédric Le Goater
2018-06-21 1:08 ` [Qemu-devel] [PATCH 0/9] spapr: Clean up pagesize handling David Gibson
2018-06-21 6:52 ` no-reply
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=20180621111941.5a3f68cc@bahia.lan \
--to=groug@kaod.org \
--cc=abologna@redhat.com \
--cc=aik@ozlabs.ru \
--cc=clg@kaod.org \
--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).