From 67f22b6aa4f0b1a4e9562a39d4daa50f8ed0d4e9 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 3 Jul 2024 18:54:48 +0000 Subject: [PATCH] hypervisor: mshv: fix GVA translation flags Original we checked for R and W, but that code path never got executed. It is now understood that we can only get here when we execute code. Fix the permission flags. Signed-off-by: Wei Liu --- hypervisor/src/mshv/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 1889de570..c8285c231 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -1526,8 +1526,10 @@ impl<'a> MshvEmulatorContext<'a> { return Ok(self.map.1); } - // TODO: More fine-grained control for the flags - let flags = HV_TRANSLATE_GVA_VALIDATE_READ | HV_TRANSLATE_GVA_VALIDATE_WRITE; + // We can only get into here when executing guest code. Check for R and X permissions. In + // the future if we have other use cases, we may want to allow the caller to specify the + // flags. + let flags = HV_TRANSLATE_GVA_VALIDATE_READ | HV_TRANSLATE_GVA_VALIDATE_EXECUTE; let (gpa, result_code) = self .vcpu