Re: [PATCH v19 101/130] KVM: TDX: handle ept violation/misconfig exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 01, 2024 at 09:54:07AM -0700,
Reinette Chatre <reinette.chatre@xxxxxxxxx> wrote:

> Hi Isaku,
> 
> On 5/1/2024 8:56 AM, Isaku Yamahata wrote:
> > On Tue, Apr 30, 2024 at 01:47:07PM -0700,
> > Reinette Chatre <reinette.chatre@xxxxxxxxx> wrote:
> >> On 4/3/2024 11:42 AM, Isaku Yamahata wrote:
> >>> On Mon, Apr 01, 2024 at 12:10:58PM +0800,
> >>> Chao Gao <chao.gao@xxxxxxxxx> wrote:
> >>>
> >>>>> +static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu)
> >>>>> +{
> >>>>> +	unsigned long exit_qual;
> >>>>> +
> >>>>> +	if (kvm_is_private_gpa(vcpu->kvm, tdexit_gpa(vcpu))) {
> >>>>> +		/*
> >>>>> +		 * Always treat SEPT violations as write faults.  Ignore the
> >>>>> +		 * EXIT_QUALIFICATION reported by TDX-SEAM for SEPT violations.
> >>>>> +		 * TD private pages are always RWX in the SEPT tables,
> >>>>> +		 * i.e. they're always mapped writable.  Just as importantly,
> >>>>> +		 * treating SEPT violations as write faults is necessary to
> >>>>> +		 * avoid COW allocations, which will cause TDAUGPAGE failures
> >>>>> +		 * due to aliasing a single HPA to multiple GPAs.
> >>>>> +		 */
> >>>>> +#define TDX_SEPT_VIOLATION_EXIT_QUAL	EPT_VIOLATION_ACC_WRITE
> >>>>> +		exit_qual = TDX_SEPT_VIOLATION_EXIT_QUAL;
> >>>>> +	} else {
> >>>>> +		exit_qual = tdexit_exit_qual(vcpu);
> >>>>> +		if (exit_qual & EPT_VIOLATION_ACC_INSTR) {
> >>>>
> >>>> Unless the CPU has a bug, instruction fetch in TD from shared memory causes a
> >>>> #PF. I think you can add a comment for this.
> >>>
> >>> Yes.
> >>>
> >>>
> >>>> Maybe KVM_BUG_ON() is more appropriate as it signifies a potential bug.
> >>>
> >>> Bug of what component? CPU. If so, I think KVM_EXIT_INTERNAL_ERROR +
> >>> KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON is more appropriate.
> >>>
> >>
> >> Is below what you have in mind?
> > 
> > Yes. data[0] should be the raw value of exit reason if possible.
> > data[2] should be exit_qual.  Hmm, I don't find document on data[] for
> 
> Did you perhaps intend to write "data[1] should be exit_qual" or would you
> like to see ndata = 3? I followed existing usages, for example [1] and [2],
> that have ndata = 2 with "data[1] = vcpu->arch.last_vmentry_cpu".
> 
> > KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON.
> > Qemu doesn't assumt ndata = 2. Just report all data within ndata.
> 
> I am not sure I interpreted your response correctly so I share one possible
> snippet below as I interpret it. Could you please check where I misinterpreted
> you? I could also make ndata = 3 to break the existing custom and add
> "data[2] = vcpu->arch.last_vmentry_cpu" to match existing pattern. What do you
> think?
> 
Sorry, I wasn't clear enough. I meant
  ndata = 3;
  data[0] = exit_reason.full;
  data[1] = vcpu->arch.last_vmentry_cpu;
  data[2] = exit_qual;

Because I hesitate to change the meaning of data[1] from other usage, I
appended exit_qual as data[2].

-- 
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux