From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1E1E1A08AF for ; Thu, 30 Apr 2026 19:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777575799; cv=none; b=EDCMe197AI0s7FK2mzHcEND3kha22octO8DjxKsfUknQuBMEYkePMD1RbwrZbyzjL0Ta/34JFSZgbeQqb70ql2SgNqG/V84Hq4cnkcuPllJ5K2xMN32muMFLPIPS7mg6hA4Kb075d3nfTNWadWZSWBoK8lfDYKdhZIBi+oJY3po= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777575799; c=relaxed/simple; bh=rhwUho6yoZ07MmJcqhTRzrKOVoru0E/tIqnep00ikhs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Gat+LTVWxaOMPOLlnZxAlnMvLbnuDLDJyy7gNw8EKi4iQyDWYC3NLDcwbbGwQFF0S26MoH8TxFAv/Zrtlgx0858JYD33/hJY8WOD7yTvY/SgHHfMkBWF5U9c721TmCd94XEDn811isRiKgL4kv2j6WPwvb/mvWxsRajq86YP9bc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pQ0210ik; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pQ0210ik" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-82f9429f49cso1645698b3a.3 for ; Thu, 30 Apr 2026 12:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777575796; x=1778180596; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=KZQTc56VieBq4iKhMHjHZ1mJOLehd0ZXe5Bs1H9JyO8=; b=pQ0210ikO891g9nUiZeGcwuBFp7meA5HwE1q/9PJdswPiyO4CTbtYZF0KkY5x1ESVo gUTyFOpQV+DqAyFo6D3kOgHwip4x0coezrmbBfW+S4pf02+nPhbugJY7oe6owN0EcGUU fSLYAdYZFaGFMF44MDaBnmGhorveuO/X2tQ8LyhU6niEjMB/PwzZ/P4g0N3fCvpds0lE sy7CSwibP7uCVRZ2e6cfDCOgbqWFDRjPTDocfA04/GmlURzwVZ/qVXOJYC08iF0ijv6k hAS0mPY5ZOLtvkwaSxiDssTMmnk/3N3J7LoOb7GGiBuFSsxcZuIzkcg/zpeS+LFqmheO 0BWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777575796; x=1778180596; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KZQTc56VieBq4iKhMHjHZ1mJOLehd0ZXe5Bs1H9JyO8=; b=PRbenSksxqyMUyJCvY6X+/I5Qkp1R6/7BUskEgT84xnLUFOy3peU+5/0A9gR1Aa5xl jkAoO07KjWrm9ZhznXqKXpsyB6hIJf0ed2YT5WIrLtc0TzNgMDHeksigcWjTnjt/73E/ xhy1bM+e3eqUijmEFfRPEzm4/OJW/aW2GZBB+R9AyV/qpYddLhaxVO3LyxByePzwgOq4 FkTSlBOrJfMXNEL2dkNrgGsU0uLj0iEnmLJVxDaGi5o+ifZo8sTqocyKml5Nud5kXhyp hdkgrTXwv+v0PM5qDEXEl9AArVzKy89mmSRJkpHrDPxS4Tspu/igy94aEC0LGeTchM6u 4TGA== X-Gm-Message-State: AOJu0Yyti403MjOoSYm4Q2PnhrUHM3iRfpRhI13pWZuxjeSC+mApMQI4 ADcLyXeQHhr/rR4WMIoDyWtWMIwKKxOOW24bUGWluRgymJICqAvPkrMeH9iABFS2TTr59j52dQf IJV4h6g== X-Received: from pfww6-n2.prod.google.com ([2002:a05:6a00:8886:20b0:82f:b21c:a00c]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:a256:b0:834:df57:9d31 with SMTP id d2e1a72fcca58-834fdba7411mr4729827b3a.28.1777575795978; Thu, 30 Apr 2026 12:03:15 -0700 (PDT) Date: Thu, 30 Apr 2026 12:03:14 -0700 In-Reply-To: <20260430150747.76749-18-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260430150747.76749-1-pbonzini@redhat.com> <20260430150747.76749-18-pbonzini@redhat.com> Message-ID: Subject: Re: [PATCH 17/28] KVM: nVMX: pass PFERR_USER_MASK to MMU on EPT violations From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, d.riley@proxmox.com, jon@nutanix.com Content-Type: text/plain; charset="us-ascii" On Thu, Apr 30, 2026, Paolo Bonzini wrote: > For EPT, PFERR_USER_MASK refers not to the CPL of the guest, > but to the AND of the U bits encountered while walking guest > page tables; this is consistent with how MBEC differentiates > between XS and XU. This is available through the > "advanced vmexit information for EPT violations" feature. > > Tested-by: David Riley > Signed-off-by: Paolo Bonzini > --- > arch/x86/kvm/vmx/common.h | 6 +++++- > arch/x86/kvm/vmx/vmx.c | 10 ++++++++++ > 2 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h > index 40fa72f31fc7..48520fa1c8e8 100644 > --- a/arch/x86/kvm/vmx/common.h > +++ b/arch/x86/kvm/vmx/common.h > @@ -100,9 +100,13 @@ static inline int __vmx_handle_ept_violation(struct kvm_vcpu *vcpu, gpa_t gpa, > error_code |= (exit_qualification & EPT_VIOLATION_PROT_USER_EXEC) > ? PFERR_PRESENT_MASK : 0; > > - if (exit_qualification & EPT_VIOLATION_GVA_IS_VALID) > + if (exit_qualification & EPT_VIOLATION_GVA_IS_VALID) { > error_code |= (exit_qualification & EPT_VIOLATION_GVA_TRANSLATED) ? > PFERR_GUEST_FINAL_MASK : PFERR_GUEST_PAGE_MASK; > + if ((exit_qualification & (EPT_VIOLATION_GVA_TRANSLATED|EPT_VIOLATION_GVA_USER)) > + == (EPT_VIOLATION_GVA_TRANSLATED|EPT_VIOLATION_GVA_USER)) Ow. Maybe add a helper or a local const u64? Actually, no need, just drop the ternary operator above: if (exit_qualification & EPT_VIOLATION_GVA_IS_VALID) { if (exit_qualification & EPT_VIOLATION_GVA_TRANSLATED) { error_code |= PFERR_GUEST_FINAL_MASK; if (exit_qualification & EPT_VIOLATION_GVA_USER) error_code |= PFERR_USER_MASK; } else { error_code |= PFERR_GUEST_PAGE_MASK; } }