[<prev] [next>] [day] [month] [year] [list]
Message-ID: <03592298-4390-4111-870b-129b6be98d3a@intel.com>
Date: Thu, 14 Mar 2024 14:46:38 -0700
From: "Chen, Zide" <zide.chen@...el.com>
To: Sagi Shahar <sagis@...gle.com>, linux-kselftest@...r.kernel.org,
Ackerley Tng <ackerleytng@...gle.com>, "Afranji, Ryan" <afranji@...gle.com>,
"Aktas, Erdem" <erdemaktas@...gle.com>, Sagi Shahar <sagis@...gle.com>,
"Yamahata, Isaku" <isaku.yamahata@...el.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>, Shuah Khan <shuah@...nel.org>,
Peter Gonda <pgonda@...gle.com>, "Xu, Haibo1" <haibo1.xu@...el.com>,
Chao Peng <chao.p.peng@...ux.intel.com>,
"Annapurve, Vishal" <vannapurve@...gle.com>,
Roger Wang <runanwang@...gle.com>, Vipin Sharma <vipinsh@...gle.com>,
jmattson@...gle.com, dmatlack@...gle.com, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [RFC PATCH v5 27/29] KVM: selftests: Propagate
KVM_EXIT_MEMORY_FAULT to userspace
On 12/12/2023 12:47 PM, Shashar, Sagi wrote:
>
>
> -----Original Message-----
> From: Sagi Shahar <sagis@...gle.com>
> Sent: Tuesday, December 12, 2023 12:47 PM
> To: linux-kselftest@...r.kernel.org; Ackerley Tng <ackerleytng@...gle.com>; Afranji, Ryan <afranji@...gle.com>; Aktas, Erdem <erdemaktas@...gle.com>; Sagi Shahar <sagis@...gle.com>; Yamahata, Isaku <isaku.yamahata@...el.com>
> Cc: Sean Christopherson <seanjc@...gle.com>; Paolo Bonzini <pbonzini@...hat.com>; Shuah Khan <shuah@...nel.org>; Peter Gonda <pgonda@...gle.com>; Xu, Haibo1 <haibo1.xu@...el.com>; Chao Peng <chao.p.peng@...ux.intel.com>; Annapurve, Vishal <vannapurve@...gle.com>; Roger Wang <runanwang@...gle.com>; Vipin Sharma <vipinsh@...gle.com>; jmattson@...gle.com; dmatlack@...gle.com; linux-kernel@...r.kernel.org; kvm@...r.kernel.org; linux-mm@...ck.org
> Subject: [RFC PATCH v5 27/29] KVM: selftests: Propagate KVM_EXIT_MEMORY_FAULT to userspace
>
> Allow userspace to handle KVM_EXIT_MEMORY_FAULT instead of triggering TEST_ASSERT.
>
> From the KVM_EXIT_MEMORY_FAULT documentation:
> Note! KVM_EXIT_MEMORY_FAULT is unique among all KVM exit reasons in that it accompanies a return code of '-1', not '0'! errno will always be set to EFAULT or EHWPOISON when KVM exits with KVM_EXIT_MEMORY_FAULT, userspace should assume kvm_run.exit_reason is stale/undefined for all other error numbers.
If KVM exits to userspace with KVM_EXIT_MEMORY_FAULT, most likely it's because the guest attempts to access the gfn in a way that is different from what the KVM is configured, in terms of private/shared property. I'd suggest to drop this patch and work on the selftests code to eliminate this exit.
If we need a testcase to catch this exit intentionally, we may call _vcpu_run() directly from the testcase and keep the common API vcpu_run() intact.
>
> Signed-off-by: Sagi Shahar <sagis@...gle.com>
> ---
> tools/testing/selftests/kvm/lib/kvm_util.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
> index d024abc5379c..8fb041e51484 100644
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -1742,6 +1742,10 @@ void vcpu_run(struct kvm_vcpu *vcpu) {
> int ret = _vcpu_run(vcpu);
>
> + // Allow this scenario to be handled by the caller.
> + if (ret == -1 && errno == EFAULT)
> + return;
> +
> TEST_ASSERT(!ret, KVM_IOCTL_ERROR(KVM_RUN, ret)); }
>
> --
> 2.43.0.472.g3155946c3a-goog
>
Powered by blists - more mailing lists