diff mbox series

[v2,2/4] KVM: arm64: Don't WARN from __pkvm_host_share_guest()

Message ID 20250225015327.3708420-3-qperret@google.com (mailing list archive)
State New
Headers show
Series Selftest for pKVM ownership transitions | expand

Commit Message

Quentin Perret Feb. 25, 2025, 1:53 a.m. UTC
We currently WARN() if the host attempts to share a page that is not in
an acceptable state with a guest. This isn't strictly necessary and
makes testing much harder, so drop the WARN and fix the error code.

Signed-off-by: Quentin Perret <qperret@google.com>
---
 arch/arm64/kvm/hyp/nvhe/mem_protect.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Marc Zyngier Feb. 25, 2025, 6:02 p.m. UTC | #1
On Tue, 25 Feb 2025 01:53:25 +0000,
Quentin Perret <qperret@google.com> wrote:
> 
> We currently WARN() if the host attempts to share a page that is not in
> an acceptable state with a guest. This isn't strictly necessary and
> makes testing much harder, so drop the WARN and fix the error code.

Are you really fixing the error code? You still seem to return a
-EPERM. I guess this was never reachable thanks to WARN() being a
panic with pKVM?

	M.

> 
> Signed-off-by: Quentin Perret <qperret@google.com>
> ---
>  arch/arm64/kvm/hyp/nvhe/mem_protect.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> index 19c3c631708c..ae39abc7e604 100644
> --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> @@ -912,7 +912,6 @@ int __pkvm_host_share_guest(u64 pfn, u64 gfn, struct pkvm_hyp_vcpu *vcpu,
>  		if (page->host_share_guest_count)
>  			break;
>  		/* Only host to np-guest multi-sharing is tolerated */
> -		WARN_ON(1);
>  		fallthrough;
>  	default:
>  		ret = -EPERM;
> -- 
> 2.48.1.658.g4767266eb4-goog
> 
>
Quentin Perret Feb. 25, 2025, 7:49 p.m. UTC | #2
On Tuesday 25 Feb 2025 at 18:02:02 (+0000), Marc Zyngier wrote:
> On Tue, 25 Feb 2025 01:53:25 +0000,
> Quentin Perret <qperret@google.com> wrote:
> > 
> > We currently WARN() if the host attempts to share a page that is not in
> > an acceptable state with a guest. This isn't strictly necessary and
> > makes testing much harder, so drop the WARN and fix the error code.
> 
> Are you really fixing the error code? You still seem to return a
> -EPERM. I guess this was never reachable thanks to WARN() being a
> panic with pKVM?

Exactly, this is really poor wording in the commit message. 'Fix the
error code' in this case was intended to mean 'make sure to return the
error code properly instead outright crashing the device'.

Happy to send out a v3 with a better commit message.

Thanks!
Quentin
Marc Zyngier Feb. 26, 2025, 2:21 p.m. UTC | #3
On Tue, 25 Feb 2025 19:49:43 +0000,
Quentin Perret <qperret@google.com> wrote:
> 
> On Tuesday 25 Feb 2025 at 18:02:02 (+0000), Marc Zyngier wrote:
> > On Tue, 25 Feb 2025 01:53:25 +0000,
> > Quentin Perret <qperret@google.com> wrote:
> > > 
> > > We currently WARN() if the host attempts to share a page that is not in
> > > an acceptable state with a guest. This isn't strictly necessary and
> > > makes testing much harder, so drop the WARN and fix the error code.
> > 
> > Are you really fixing the error code? You still seem to return a
> > -EPERM. I guess this was never reachable thanks to WARN() being a
> > panic with pKVM?
> 
> Exactly, this is really poor wording in the commit message. 'Fix the
> error code' in this case was intended to mean 'make sure to return the
> error code properly instead outright crashing the device'.
> 
> Happy to send out a v3 with a better commit message.

Nah, that's probably something Oliver can fixup when picking up the
patch.

Thanks,

	M.
diff mbox series

Patch

diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
index 19c3c631708c..ae39abc7e604 100644
--- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
+++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
@@ -912,7 +912,6 @@  int __pkvm_host_share_guest(u64 pfn, u64 gfn, struct pkvm_hyp_vcpu *vcpu,
 		if (page->host_share_guest_count)
 			break;
 		/* Only host to np-guest multi-sharing is tolerated */
-		WARN_ON(1);
 		fallthrough;
 	default:
 		ret = -EPERM;