From: Michael Ellerman <mpe@ellerman.id.au> To: Claudio Carvalho <cclaudio@linux.ibm.com>, linuxppc-dev@ozlabs.org Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>, Michael Anderson <andmike@linux.ibm.com>, Ram Pai <linuxram@us.ibm.com>, Claudio Carvalho <cclaudio@linux.ibm.com>, kvm-ppc@vger.kernel.org, Bharata B Rao <bharata@linux.ibm.com>, Ryan Grimm <grimm@linux.ibm.com>, Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>, Guerney Hunt <gdhh@linux.ibm.com>, Thiago Bauermann <bauerman@linux.ibm.com> Subject: Re: [PATCH v5 5/7] powerpc/mm: Write to PTCR only if ultravisor disabled Date: Wed, 14 Aug 2019 22:04:49 +1000 [thread overview] Message-ID: <87wofg6jha.fsf@concordia.ellerman.id.au> (raw) In-Reply-To: <20190808040555.2371-6-cclaudio@linux.ibm.com> Claudio Carvalho <cclaudio@linux.ibm.com> writes: > In ultravisor enabled systems, PTCR becomes ultravisor privileged only > for writing and an attempt to write to it will cause a Hypervisor > Emulation Assitance interrupt. > > This patch adds the try_set_ptcr(val) macro as an accessor to > mtspr(SPRN_PTCR, val), which will be executed only if ultravisor > disabled. > > Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com> > --- > arch/powerpc/include/asm/reg.h | 13 +++++++++++++ > arch/powerpc/mm/book3s64/hash_utils.c | 4 ++-- > arch/powerpc/mm/book3s64/pgtable.c | 2 +- > arch/powerpc/mm/book3s64/radix_pgtable.c | 6 +++--- > 4 files changed, 19 insertions(+), 6 deletions(-) > > diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h > index 10caa145f98b..14139b1ebdb8 100644 > --- a/arch/powerpc/include/asm/reg.h > +++ b/arch/powerpc/include/asm/reg.h > @@ -15,6 +15,7 @@ > #include <asm/cputable.h> > #include <asm/asm-const.h> > #include <asm/feature-fixups.h> > +#include <asm/firmware.h> reg.h is already too big and unwieldy. Can you put this in ultravisor.h and include that in the appropriate places. > @@ -1452,6 +1453,18 @@ static inline void update_power8_hid0(unsigned long hid0) > */ > asm volatile("sync; mtspr %0,%1; isync":: "i"(SPRN_HID0), "r"(hid0)); > } > + > +/* > + * In ultravisor enabled systems, PTCR becomes ultravisor privileged only for > + * writing and an attempt to write to it will cause a Hypervisor Emulation > + * Assistance interrupt. > + */ > +#define try_set_ptcr(val) \ > + do { \ > + if (!firmware_has_feature(FW_FEATURE_ULTRAVISOR)) \ > + mtspr(SPRN_PTCR, val); \ > + } while (0) This should be a static inline please, not a macro. Sorry, I don't like the name, we're not trying to set it, we know when to set it and when not to. It is awkward to come up with a good name because we don't have a term for "hypervisor that's not running under an ultravisor". Maybe set_ptcr_when_no_uv() Which is kinda messy, someone feel free to come up with something better. I also see some more accesses to the PTCR in arch/powerpc/platforms/powernv/idle.c which you haven't patched? cheers
WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <mpe@ellerman.id.au> To: Claudio Carvalho <cclaudio@linux.ibm.com>, linuxppc-dev@ozlabs.org Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>, Michael Anderson <andmike@linux.ibm.com>, Ram Pai <linuxram@us.ibm.com>, Claudio Carvalho <cclaudio@linux.ibm.com>, kvm-ppc@vger.kernel.org, Bharata B Rao <bharata@linux.ibm.com>, Ryan Grimm <grimm@linux.ibm.com>, Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>, Guerney Hunt <gdhh@linux.ibm.com>, Thiago Bauermann <bauerman@linux.ibm.com> Subject: Re: [PATCH v5 5/7] powerpc/mm: Write to PTCR only if ultravisor disabled Date: Wed, 14 Aug 2019 12:04:49 +0000 [thread overview] Message-ID: <87wofg6jha.fsf@concordia.ellerman.id.au> (raw) In-Reply-To: <20190808040555.2371-6-cclaudio@linux.ibm.com> Claudio Carvalho <cclaudio@linux.ibm.com> writes: > In ultravisor enabled systems, PTCR becomes ultravisor privileged only > for writing and an attempt to write to it will cause a Hypervisor > Emulation Assitance interrupt. > > This patch adds the try_set_ptcr(val) macro as an accessor to > mtspr(SPRN_PTCR, val), which will be executed only if ultravisor > disabled. > > Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com> > --- > arch/powerpc/include/asm/reg.h | 13 +++++++++++++ > arch/powerpc/mm/book3s64/hash_utils.c | 4 ++-- > arch/powerpc/mm/book3s64/pgtable.c | 2 +- > arch/powerpc/mm/book3s64/radix_pgtable.c | 6 +++--- > 4 files changed, 19 insertions(+), 6 deletions(-) > > diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h > index 10caa145f98b..14139b1ebdb8 100644 > --- a/arch/powerpc/include/asm/reg.h > +++ b/arch/powerpc/include/asm/reg.h > @@ -15,6 +15,7 @@ > #include <asm/cputable.h> > #include <asm/asm-const.h> > #include <asm/feature-fixups.h> > +#include <asm/firmware.h> reg.h is already too big and unwieldy. Can you put this in ultravisor.h and include that in the appropriate places. > @@ -1452,6 +1453,18 @@ static inline void update_power8_hid0(unsigned long hid0) > */ > asm volatile("sync; mtspr %0,%1; isync":: "i"(SPRN_HID0), "r"(hid0)); > } > + > +/* > + * In ultravisor enabled systems, PTCR becomes ultravisor privileged only for > + * writing and an attempt to write to it will cause a Hypervisor Emulation > + * Assistance interrupt. > + */ > +#define try_set_ptcr(val) \ > + do { \ > + if (!firmware_has_feature(FW_FEATURE_ULTRAVISOR)) \ > + mtspr(SPRN_PTCR, val); \ > + } while (0) This should be a static inline please, not a macro. Sorry, I don't like the name, we're not trying to set it, we know when to set it and when not to. It is awkward to come up with a good name because we don't have a term for "hypervisor that's not running under an ultravisor". Maybe set_ptcr_when_no_uv() Which is kinda messy, someone feel free to come up with something better. I also see some more accesses to the PTCR in arch/powerpc/platforms/powernv/idle.c which you haven't patched? cheers
next prev parent reply other threads:[~2019-08-14 12:07 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-08 4:05 [PATCH v5 0/7] kvmppc: Paravirtualize KVM to support ultravisor Claudio Carvalho 2019-08-08 4:05 ` Claudio Carvalho 2019-08-08 4:05 ` [PATCH v5 1/7] Documentation/powerpc: Ultravisor API Claudio Carvalho 2019-08-08 4:05 ` Claudio Carvalho 2019-08-09 12:45 ` Michael Ellerman 2019-08-09 12:45 ` Michael Ellerman 2019-08-21 22:30 ` Claudio Carvalho 2019-08-21 22:30 ` Claudio Carvalho 2019-08-12 15:58 ` Fabiano Rosas 2019-08-12 15:58 ` Fabiano Rosas 2019-08-21 22:01 ` Claudio Carvalho 2019-08-21 22:01 ` Claudio Carvalho 2019-08-08 4:05 ` [PATCH v5 2/7] powerpc/kernel: Add ucall_norets() ultravisor call handler Claudio Carvalho 2019-08-08 4:05 ` Claudio Carvalho 2019-08-14 10:46 ` Michael Ellerman 2019-08-14 10:46 ` Michael Ellerman 2019-08-14 18:34 ` Segher Boessenkool 2019-08-14 18:34 ` Segher Boessenkool 2019-08-22 1:26 ` Claudio Carvalho 2019-08-22 1:26 ` Claudio Carvalho 2019-08-22 1:24 ` Claudio Carvalho 2019-08-22 1:24 ` Claudio Carvalho 2019-08-08 4:05 ` [PATCH v5 3/7] powerpc/powernv: Introduce FW_FEATURE_ULTRAVISOR Claudio Carvalho 2019-08-08 4:05 ` Claudio Carvalho 2019-08-08 4:05 ` [PATCH v5 4/7] powerpc/mm: Use UV_WRITE_PATE ucall to register a PATE Claudio Carvalho 2019-08-08 4:05 ` Claudio Carvalho 2019-08-14 11:33 ` Michael Ellerman 2019-08-14 11:33 ` Michael Ellerman 2019-08-21 0:04 ` Sukadev Bhattiprolu 2019-08-21 0:04 ` Sukadev Bhattiprolu 2019-08-22 1:33 ` Claudio Carvalho 2019-08-22 1:33 ` Claudio Carvalho 2019-08-08 4:05 ` [PATCH v5 5/7] powerpc/mm: Write to PTCR only if ultravisor disabled Claudio Carvalho 2019-08-08 4:05 ` Claudio Carvalho 2019-08-14 12:04 ` Michael Ellerman [this message] 2019-08-14 12:04 ` Michael Ellerman 2019-08-08 4:05 ` [PATCH v5 6/7] powerpc/powernv: Access LDBAR " Claudio Carvalho 2019-08-08 4:05 ` Claudio Carvalho 2019-08-08 4:05 ` [PATCH v5 7/7] powerpc/kvm: Use UV_RETURN ucall to return to ultravisor Claudio Carvalho 2019-08-08 4:05 ` Claudio Carvalho
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=87wofg6jha.fsf@concordia.ellerman.id.au \ --to=mpe@ellerman.id.au \ --cc=andmike@linux.ibm.com \ --cc=bauerman@linux.ibm.com \ --cc=bharata@linux.ibm.com \ --cc=cclaudio@linux.ibm.com \ --cc=gdhh@linux.ibm.com \ --cc=grimm@linux.ibm.com \ --cc=kvm-ppc@vger.kernel.org \ --cc=linuxppc-dev@ozlabs.org \ --cc=linuxram@us.ibm.com \ --cc=maddy@linux.vnet.ibm.com \ --cc=sukadev@linux.vnet.ibm.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.