[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230428191733.3428555-1-afranji@google.com>
Date: Fri, 28 Apr 2023 19:17:33 +0000
From: Ryan Afranji <afranji@...gle.com>
To: isaku.yamahata@...el.com
Cc: dmatlack@...gle.com, erdemaktas@...gle.com,
isaku.yamahata@...il.com, kai.huang@...el.com, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, pbonzini@...hat.com,
sagis@...gle.com, seanjc@...gle.com, zhi.wang.linux@...il.com
Subject: Re: [PATCH v13 098/113] KVM: TDX: Handle TDX PV map_gpa hypercall
+static int tdx_map_gpa(struct kvm_vcpu *vcpu)
+{
+ struct kvm *kvm = vcpu->kvm;
+ gpa_t gpa = tdvmcall_a0_read(vcpu);
+ gpa_t size = tdvmcall_a1_read(vcpu);
+ gpa_t end = gpa + size;
+
+ if (!IS_ALIGNED(gpa, PAGE_SIZE) || !IS_ALIGNED(size, PAGE_SIZE) ||
+ end < gpa ||
+ end > kvm_gfn_shared_mask(kvm) << (PAGE_SHIFT + 1) ||
+ kvm_is_private_gpa(kvm, gpa) != kvm_is_private_gpa(kvm, end)) {
+ tdvmcall_set_return_code(vcpu, TDG_VP_VMCALL_INVALID_OPERAND);
According to table 3-6 of the GHCI spec, TDG.VP.VMCALL_ALIGN_ERROR should be
returned if there is an alignment error for the size or start GPA. Right now,
TDG_VP_VMCALL_INVALID_OPERAND is being returned instead. Can this be updated?
+ return 1;
+ }
+
+ return tdx_vp_vmcall_to_user(vcpu);
+}
+
Powered by blists - more mailing lists