From: Paul Mackerras Date: Wed, 31 Mar 2021 04:08:25 +0000 Subject: Re: [PATCH v4 02/46] KVM: PPC: Book3S HV: Add a function to filter guest LPCR bits Message-Id: List-Id: References: <20210323010305.1045293-1-npiggin@gmail.com> <20210323010305.1045293-3-npiggin@gmail.com> In-Reply-To: <20210323010305.1045293-3-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Nicholas Piggin Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org On Tue, Mar 23, 2021 at 11:02:21AM +1000, Nicholas Piggin wrote: > Guest LPCR depends on hardware type, and future changes will add > restrictions based on errata and guest MMU mode. Move this logic > to a common function and use it for the cases where the guest > wants to update its LPCR (or the LPCR of a nested guest). [snip] > @@ -4641,8 +4662,9 @@ void kvmppc_update_lpcr(struct kvm *kvm, unsigned long lpcr, unsigned long mask) > struct kvmppc_vcore *vc = kvm->arch.vcores[i]; > if (!vc) > continue; > + > spin_lock(&vc->lock); > - vc->lpcr = (vc->lpcr & ~mask) | lpcr; > + vc->lpcr = kvmppc_filter_lpcr_hv(vc, (vc->lpcr & ~mask) | lpcr); This change seems unnecessary, since kvmppc_update_lpcr is called only to update MMU configuration bits, not as a result of any action by userspace or a nested hypervisor. It's also beyond the scope of what was mentioned in the commit message. Paul.