From nobody Fri Dec 19 16:53:36 2025 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 CCBD274E09 for ; Sat, 15 Feb 2025 01:14:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582083; cv=none; b=jQ9p9uNmk+XM6qd5dOPB8vxCf53+oDY7HkiHmRNIjCUvCX6VqEJJbsPRe7PKfvBvcfAlUlxmZprC6zoR8/Z9q56OOxX80fgFVZqMTVwuhIF6WVqvbZFfHaV8H4y01Uu3UQY0sPxC1SbdmDw3hI2JueZs3cCLhOcUt9GFMO3MyA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582083; c=relaxed/simple; bh=5xz8jYzPHf6amN47H298De5D9Y9tv1lp18wh8jahuOA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=c9d0pVo3l9NXK21docJh4slgN+IkDlis0IrQaoLjh9wKXuIGSPfqT3RVWwTv3lXggX3AKcZL2bNu1QoV8AjlpQTJed2CpHU97JbYpNWHa0CQB8+sxm0PPORtm8bmjhaquzTw3fOlKbrc5+zbkx1A6I4C2FxRRNF8IuKZCtVQLok= 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=fKqYx03f; arc=none smtp.client-ip=209.85.214.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="fKqYx03f" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-220fff23644so14695015ad.0 for ; Fri, 14 Feb 2025 17:14:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739582081; x=1740186881; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=GLdih/SuzIjNw6oPbBJsSyQpCg9vqoYPBoF6JqvqcU0=; b=fKqYx03fSRk0KWaQ0vKK7pE93MNuapj66D+iGOq9iN7aAHeo1HTdZ7zbMt3qOIik6H tmNi648gvc79IIwK7mZy45a4delXqJOnLrGiEfyhR8CHNDzUa4csuDb91tKA7LcnkIBB EQXBPvwtVcO5Q8Lxs+B2MziexU1wJVEhz2PgjL7jUyMElY3Zggrm+Jzjy/9zbStYmruP DcjgH7jE/FlB1RhIHbQTsZN5KxFJ26AbVqWcxdChDh2TFc5X6CnNeKy4MHHeiXlsTorw GVuBXr+fX1RFCHE4TmOxy/pVmDiwK7hSVkMOtpIER9XY3xWgdvImUFvLlH5opkfQarXA K08w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739582081; x=1740186881; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GLdih/SuzIjNw6oPbBJsSyQpCg9vqoYPBoF6JqvqcU0=; b=BDrBT/knBiVw48t2flhkRHeX5XaOJFVJwfnGISzkbaKgWNege7Y6KVn/7FP1xaK+AE /AQgBQ/kz90kO5t9f0IuIzn5V18D3/vznWZvxMt8WD5L+MlXybQyWmzAi34NJ8v2hXF7 N5CaPkEr4bh/y/U0buvRgKzycF0kOud0WMbVvViKn9yRHCZ7urFlKnhHP/5vkK6hwvWY 95qOcN6lK5PmO/bBKSF0Ku4URsSfDJDONcYuMughxnmPk/ipzGYolapSVEIkuP1JgrZy N5UAQACFzcJ+hePLZ/ZsgdU/ULZYLxLsdPSsKkf2+I4FaDceKM0qZVf1CgzUx0RMxpvh rzAA== X-Forwarded-Encrypted: i=1; AJvYcCWXJthcqyLyV8snUD34QDZqciXIKtTlyccHTIxTSoaXMH9rJeLmdL7BW6zLJWr97Vh2WBrdxwY4meJKwV8=@vger.kernel.org X-Gm-Message-State: AOJu0Yyxd4/w+ubLG2JWcAk58c7zv672uS3wE9Pl4goCdhi5D9YdlWv5 02EG3BUAHTHWH3lCpTFnaf3cGIM8z4jxQPzV+CKbc3DWIxLeSFvvYLS0cN1CeufXLzk2KVUf0IR THg== X-Google-Smtp-Source: AGHT+IFZUvzAbZYpqr2AjgrHoxhevdhJ9HY2uplUSiVhOtxQe9AbMED3arOME3GI3dmwMldwaM//5r5OIG4= X-Received: from pfbgb10.prod.google.com ([2002:a05:6a00:628a:b0:731:9461:420e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:a91:b0:1ee:40e2:8f51 with SMTP id adf61e73a8af0-1ee8cc4c56dmr2573341637.42.1739582081022; Fri, 14 Feb 2025 17:14:41 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 14 Feb 2025 17:14:33 -0800 In-Reply-To: <20250215011437.1203084-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250215011437.1203084-1-seanjc@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Message-ID: <20250215011437.1203084-2-seanjc@google.com> Subject: [PATCH v2 1/5] KVM: x86/xen: Restrict hypercall MSR to unofficial synthetic range From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joao Martins , David Woodhouse Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reject userspace attempts to set the Xen hypercall page MSR to an index outside of the "standard" virtualization range [0x40000000, 0x4fffffff], as KVM is not equipped to handle collisions with real MSRs, e.g. KVM doesn't update MSR interception, conflicts with VMCS/VMCB fields, special case writes in KVM, etc. While the MSR index isn't strictly ABI, i.e. can theoretically float to any value, in practice no known VMM sets the MSR index to anything other than 0x40000000 or 0x40000200. Cc: Joao Martins Reviewed-by: David Woodhouse Reviewed-by: Paul Durrant Signed-off-by: Sean Christopherson --- arch/x86/include/uapi/asm/kvm.h | 3 +++ arch/x86/kvm/xen.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kv= m.h index 9e75da97bce0..460306b35a4b 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -559,6 +559,9 @@ struct kvm_x86_mce { #define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7) #define KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA (1 << 8) =20 +#define KVM_XEN_MSR_MIN_INDEX 0x40000000u +#define KVM_XEN_MSR_MAX_INDEX 0x4fffffffu + struct kvm_xen_hvm_config { __u32 flags; __u32 msr; diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index a909b817b9c0..5b94825001a7 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1324,6 +1324,15 @@ int kvm_xen_hvm_config(struct kvm *kvm, struct kvm_x= en_hvm_config *xhc) xhc->blob_size_32 || xhc->blob_size_64)) return -EINVAL; =20 + /* + * Restrict the MSR to the range that is unofficially reserved for + * synthetic, virtualization-defined MSRs, e.g. to prevent confusing + * KVM by colliding with a real MSR that requires special handling. + */ + if (xhc->msr && + (xhc->msr < KVM_XEN_MSR_MIN_INDEX || xhc->msr > KVM_XEN_MSR_MAX_INDEX= )) + return -EINVAL; + mutex_lock(&kvm->arch.xen.xen_lock); =20 if (xhc->msr && !kvm->arch.xen_hvm_config.msr) --=20 2.48.1.601.g30ceb7b040-goog From nobody Fri Dec 19 16:53:36 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 7D24B13AD1C for ; Sat, 15 Feb 2025 01:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582084; cv=none; b=C2buqB1sywupfkeUGyRxEqtvrFaOEsusBrkeN/UvHWjUIbAfkWcbBdJ/uZKlbh/YoRnH23gssOjbikUpGedF0F6zF2wglQSAkMiqvQOqE41+EOW37K7RcU96WanetWnHHo8UKPghozf5QHcm1rC7U+OiF/KgEDLaMcIs/sceENo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582084; c=relaxed/simple; bh=JbnvHaDptxn9NsbJMw3UZ8db940ba/YMp/UB9zJLz0k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=koTITtWESxza5VTaG1N67xO7OMJOuB8HtB+yLNyhbBYkxvYqeEgIH/FYiphQFr6J6LQrQRuUWVc5ks2EyNnfefHWh0tRfSbfh1a+JzPjbuEaEZZlTs0PxHd1J3yvid87/9n5tRDJp+2sNJynm23zmuOQoP9/Uwvqjay0m0++2sY= 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=BgE/8kVj; arc=none smtp.client-ip=209.85.216.74 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="BgE/8kVj" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2f2a9f056a8so5473054a91.2 for ; Fri, 14 Feb 2025 17:14:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739582083; x=1740186883; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=Q49hFnWXm1R0ExDb7g/KnSF2lPa5FS0gZ3iojWO2T5A=; b=BgE/8kVj4LXa5SEfCCcYIYy2360/CFrjQFAzSybIVXQzBgjDZJjsAE8dBP0GzUMYUG Tn8JBpkdNp20LuepheOt6YiYKxD1mHin8pmpWObuv2PZpCh4Yf1AXqOyW74a54g4vPBm 1BoHm7JYU2xxp3ExJ0n6cpGgGuWs8R8Xg3olznGsHXRBs4sl+K0qJmsWRSF7eTl9kgnE v2JdCuxmMlS6fUBFs4ipUNeSu6FfZIqb3ZeBhd9v8UhWgdMUpdCeVYOLu2GAYggKvqTm JcHnKy0KmZklQy02hA53Ka3y/qqDzyd0z8vPiKLL/hNuA1/10spkGo/TCQjStPRggpPp bfFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739582083; x=1740186883; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Q49hFnWXm1R0ExDb7g/KnSF2lPa5FS0gZ3iojWO2T5A=; b=oqCMU4rDou+PGGhZcct/xjyoWXwvc9BF5fHFuvomlkIGtkvUPe5W2qf+hX6sjz01Gr q5amdbbt6ocJVuJzQH9yaKUsVhGsUuf8P9EXTSMLtJsMmyO1UFynjsSoQfK2gdcmjGW7 4moGyat+UY97ofWUpEtTdwhRmehJX4brKlz/TP5qcga3trcqAvVJZcXxMrJWqirO56Y2 LWVEZiqoW5GNE4q3RPvRAVRBILiifnanHZ54ZR5sVhau8xWAnXdFkuu2N7nDkYGSqdrV xDFeaXPC0M8Dja0TtBgQl7aW6kRoVGNg4CYf9X30Rz116Gc9z0R2jhJkuo5ltygmKd4y 2qxg== X-Forwarded-Encrypted: i=1; AJvYcCW0K26rxTqHMW60Gz41rqYlaEC4gj+ZSnTo/nrsI3aMQJbCsalTnMhz2lGsaimXrkLLCehgZtYAJe886q0=@vger.kernel.org X-Gm-Message-State: AOJu0YyRoEviSTpZQEzx2s6UtTsBNprD5URnMg9JJq5t5Rm5WsuWu6vJ nZyrQRDMMg4Lh8XZphnql1GSQQsBpQDLMe7X4vDi+LXYVOQjbozjldgYB6APC0ubCvxstrAy/do eTA== X-Google-Smtp-Source: AGHT+IHBkyl4PIpFpkFkqS6pqT2rwD3MsxlYDyDhMSaF0m4JLwYlAZEuhy23IIj9HKSlsdXErMSDNcJbz7A= X-Received: from pjbnb2.prod.google.com ([2002:a17:90b:35c2:b0:2fc:c98:ea47]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3949:b0:2ee:db8a:2a01 with SMTP id 98e67ed59e1d1-2fc41153d87mr1793706a91.30.1739582082789; Fri, 14 Feb 2025 17:14:42 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 14 Feb 2025 17:14:34 -0800 In-Reply-To: <20250215011437.1203084-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250215011437.1203084-1-seanjc@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Message-ID: <20250215011437.1203084-3-seanjc@google.com> Subject: [PATCH v2 2/5] KVM: x86/xen: Add an #ifdef'd helper to detect writes to Xen MSR From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joao Martins , David Woodhouse Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a helper to detect writes to the Xen hypercall page MSR, and provide a stub for CONFIG_KVM_XEN=3Dn to optimize out the check for kernels built without Xen support. Reviewed-by: Paul Durrant Reviewed-by: David Woodhouse Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 2 +- arch/x86/kvm/xen.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 462a5cd6ac4a..12c60adb7349 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3738,7 +3738,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct = msr_data *msr_info) * page setup; it could incur locking paths which are not expected * if userspace sets the MSR in an unusual location. */ - if (msr && msr =3D=3D vcpu->kvm->arch.xen_hvm_config.msr && + if (kvm_xen_is_hypercall_page_msr(vcpu->kvm, msr) && !msr_info->host_initiated) return kvm_xen_write_hypercall_page(vcpu, data); =20 diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h index f5841d9000ae..e92e06926f76 100644 --- a/arch/x86/kvm/xen.h +++ b/arch/x86/kvm/xen.h @@ -56,6 +56,11 @@ static inline bool kvm_xen_msr_enabled(struct kvm *kvm) kvm->arch.xen_hvm_config.msr; } =20 +static inline bool kvm_xen_is_hypercall_page_msr(struct kvm *kvm, u32 msr) +{ + return msr && msr =3D=3D kvm->arch.xen_hvm_config.msr; +} + static inline bool kvm_xen_hypercall_enabled(struct kvm *kvm) { return static_branch_unlikely(&kvm_xen_enabled.key) && @@ -124,6 +129,11 @@ static inline bool kvm_xen_msr_enabled(struct kvm *kvm) return false; } =20 +static inline bool kvm_xen_is_hypercall_page_msr(struct kvm *kvm, u32 msr) +{ + return false; +} + static inline bool kvm_xen_hypercall_enabled(struct kvm *kvm) { return false; --=20 2.48.1.601.g30ceb7b040-goog From nobody Fri Dec 19 16:53:36 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 14F351514EE for ; Sat, 15 Feb 2025 01:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582086; cv=none; b=G9iWhoM3cWRhwrXyXXJlX19NLgOB619U1BX2T+VKwM3g1y9mtL1hqokUgSxrs6rK+jsCLOaduBk7D8a+l/RafdF06pmhljUkdfQEvfG5rsm0NBPNvfflreBqOJuma7Dj7S1RRYLuJ94EYxWZHY3eB/N01l3/FeypquI0eDpr+hU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582086; c=relaxed/simple; bh=Nq45uqSKHEPg4dzpAAVHI0Nbkbth2NKJarH67mwYrqw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BfHE6bdpjW8oeydBgwBrBMAa/mDNimSnRvMDqnYtXP1mhe08kk36QuOdSve62eRvX81KPYau0gds2RXOLSHgV8wILNFq126+3cUFg660dVwFslTYQwOnDyglZf9gt+Af5m5u83U4cad7mu4uyoPL6Q2IBDOnOoVrbgFs5lzScPw= 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=ZmQvAmy6; arc=none smtp.client-ip=209.85.216.74 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="ZmQvAmy6" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2fc45101191so78586a91.1 for ; Fri, 14 Feb 2025 17:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739582084; x=1740186884; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=6j/gglXJS1yN/9vw2FthXhPcheEiRDBsR2pbz8PXCNU=; b=ZmQvAmy6oVbzJNNwxqGkJh2wH+/p+6/WNgY+os8wZiVBuwL2jTlyen8C0Ya4W4dKfJ MQO+28RdiVXLZUBtUDefqx8KCG4ZyL5OPKWSjnS23gtS5QZBbCGnVXLWTq45krMqn/GF oRxyELLtllONZJ1U6u3sBs5Ax3zOqsKbuA6ySMlGM+f660Me3PB1O6c24PpsZAIMJ4DA vPQXHrqMaWLDRiocl3J5l6GaJBRmmMDz6dvI1w3uBNsffeNdPDFzdmLEwax7KPOdz/bs 1SRMn6R5KQEJKLp920EY5IbJYmxKf+r59hXw+uaaQCsIVtgfd0rbB0qcmlBvi6aZIFde aDQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739582084; x=1740186884; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6j/gglXJS1yN/9vw2FthXhPcheEiRDBsR2pbz8PXCNU=; b=ss3kTAIaP08V7rTSMx5fcN0oEUYX+8wUuEkRj4F7dfkcpDK16WDZGTe95b9xf6XlJJ 5NorkXTil+cybZ2wouD/qMsi4EDBXyErhG57LvQ65/PZnudk8umPRVjB3nw8tOOzgALi CjFCzYMWKLdlevP3n1cZtgzLf4ks7ebBSlZbdg9efClTJ9LCNLQYZ+ZDJOIHNKmOsngA ASmnuH4WcB7oeqZSo2PBYlIaQZza8h5gP8WGEkyYYaLRNpV/g4I7oHgX7WDTaltcSLCo 8T2rofR4ME8QG9oAOqIob7JW3EDPn2OL+DYZfNb+GmCeGONqvbR3nqo48A0xF34lhazl 2Czg== X-Forwarded-Encrypted: i=1; AJvYcCVqYEoFNpKtGI35fXiYd1psJncajJ49LAkrQ15SN1PzJusKq47+DxYntTnhXVjSjvUwO9zZYm1lPElIXLQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxJlnl9WuIGseUWQ2/aA8tsBWHLCaSmLw8ZhgYrRELwcl3gx8+i tKgCz7Dxakaz15v8Rgg2/47WKuE4XQyiywElV6womSdkeBGo6YSfatK63/KwstaWgCrdbXFVOCA 1/Q== X-Google-Smtp-Source: AGHT+IHDz0saxK+uDPiFg1p1YwHS66b4lZqXWidBMXMNqLNQVQfSJrHTu3y8P9oy8wEHlGtCW8YLz5mUoCk= X-Received: from pjbsi4.prod.google.com ([2002:a17:90b:5284:b0:2ee:53fe:d0fc]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3f06:b0:2fc:3264:3667 with SMTP id 98e67ed59e1d1-2fc40d131bemr1894760a91.1.1739582084469; Fri, 14 Feb 2025 17:14:44 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 14 Feb 2025 17:14:35 -0800 In-Reply-To: <20250215011437.1203084-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250215011437.1203084-1-seanjc@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Message-ID: <20250215011437.1203084-4-seanjc@google.com> Subject: [PATCH v2 3/5] KVM: x86/xen: Consult kvm_xen_enabled when checking for Xen MSR writes From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joao Martins , David Woodhouse Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Query kvm_xen_enabled when detecting writes to the Xen hypercall page MSR so that the check is optimized away in the likely scenario that Xen isn't enabled for the VM. Deliberately open code the check instead of using kvm_xen_msr_enabled() in order to avoid a double load of xen_hvm_config.msr (which is admittedly rather pointless given the widespread lack of READ_ONCE() usage on the plethora of vCPU-scoped accesses to kvm->arch.xen state). No functional change intended. Reviewed-by: David Woodhouse Reviewed-by: Paul Durrant Signed-off-by: Sean Christopherson --- arch/x86/kvm/xen.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h index e92e06926f76..1e3a913dfb94 100644 --- a/arch/x86/kvm/xen.h +++ b/arch/x86/kvm/xen.h @@ -58,6 +58,9 @@ static inline bool kvm_xen_msr_enabled(struct kvm *kvm) =20 static inline bool kvm_xen_is_hypercall_page_msr(struct kvm *kvm, u32 msr) { + if (!static_branch_unlikely(&kvm_xen_enabled.key)) + return false; + return msr && msr =3D=3D kvm->arch.xen_hvm_config.msr; } =20 --=20 2.48.1.601.g30ceb7b040-goog From nobody Fri Dec 19 16:53:36 2025 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 DC3C41624C8 for ; Sat, 15 Feb 2025 01:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582088; cv=none; b=XONTVSp8CVwFipkcyrcu93nU6NCe4jrMbDWQkYGlEZbgQdeAfgVsUkabFJedOKBSyi+0uqofbxOYt13FORQ7ZeqY5w0pQSjzkqcrK6b3UEqEDt/v0qDUnmvEMWZK6fsVAc9oX55HkvNW/xDO6stjWJ/IZgWytrZzwzGgAEFXjOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582088; c=relaxed/simple; bh=V20/5Zcwsh3LkusvwxipaeAPlQmSrKGd8beRUUCMKWc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=q1eNZ1W7NEfn/RcCh0a4iYCeFozGYrlV1HeftxsKe1//iVeyOZWM4MqwTXMNsRO1VTlUIqc2ys4Ds3879GU6LYqW6FnpvYPU/ZcPYQ/EGeN7qcorP3OlRD/BZuNbzWdkFjiw/NbOK83Vqsb99hiwdIFDYb2NgUeWtu7LMn3+Ibg= 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=Rwzn+S4h; arc=none smtp.client-ip=209.85.214.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="Rwzn+S4h" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-220e1593b85so40385075ad.3 for ; Fri, 14 Feb 2025 17:14:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739582086; x=1740186886; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=j7vKBoevqSd0YmMKIcf2UgJa+X4zyjdi3hzZRBAtboE=; b=Rwzn+S4hIGg4lO+DfRTiSY4efs3/Y/cAxBcBhKr9SwwN1IJ4OS4hNcxNLrJkkLTJJn h0Pw3yE5+U31JfWy4pqYUivC/JYuAnWowf/fHtZeFgB2jbPJQW8le9TLU1MXxOWyRDBz 2NtUvHAXmXllWtXHYWM21FkVpO2ZRJEJsfOHv8NAQGsGNnl1hOVrCBuzn+PHqf0wqryY /DHO4z0b6E74WWN4bvUgshv6r4UdeKKthM7TzNLYG0HX15xlNHXMf+s6o8u/knZizIdY JyLzF17t18bsC7ykkLFm+zjVqeOv2YgOTGBCTyihitMLmGvXBOhQ0qTgGK+Ny6CvYGcZ e2vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739582086; x=1740186886; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=j7vKBoevqSd0YmMKIcf2UgJa+X4zyjdi3hzZRBAtboE=; b=iBvwKRA1PW45iy0rcfG8644+fUsmRsBY0cOpSXd7YOuWzZ7Tpfwcl/W2f1zRUCKSjT mdYjhbfI4Aud/iOBhf0HJq/xA2HrIbwFHoYXVdzieNudhxpVerW1ru8uIZMieZJofexH pTUiJWYMpVvJQVZVGHeCKymOXYYRJh/jo8eO5+EFnrF4i1A8WjugUvIzrzFP68jmKD54 W/WY9otSSz62mWQ9NtEvDc6q4AIU9V2hBJlB4BuyFmy0ReEExMDtYuy8AppULwGBPDL+ po83dUftJ/bcep/3otAyhmPoFVnlPDigw5vUAsCcKGnFAZIHXghrZEFRTFOQyopefBuf GU2g== X-Forwarded-Encrypted: i=1; AJvYcCUl7EbM6elCyBVIG1ZTkiDFqc3fN5FVJyXB2/92AFCS1fN8d9hUs9yPJns6pFjw3N6ewwIRo27DPT+OP1M=@vger.kernel.org X-Gm-Message-State: AOJu0YxaEgFhaBoetVAb8TivdCSRLWPaIUM/U8NQGXRDeTZsSdzScB3W xrV60/ojVmHwz6Kk6us3iqRkzK67FITBG5lijlaEFai1n/HjKRgJqbqxh7/0h4djt44yY9k5H6L xYg== X-Google-Smtp-Source: AGHT+IGtO3LhcclmaxlBOzDhlZWiTA4X0kQhu9BMoJyJBJrBPP1akoMVuWrkGmqqeaspC7bpVglvyuzDJl4= X-Received: from pgfp3.prod.google.com ([2002:a63:ab03:0:b0:add:f880:2c5b]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:e8c:b0:1eb:48e2:2c2f with SMTP id adf61e73a8af0-1ee8cbc1ea9mr3069398637.30.1739582086175; Fri, 14 Feb 2025 17:14:46 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 14 Feb 2025 17:14:36 -0800 In-Reply-To: <20250215011437.1203084-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250215011437.1203084-1-seanjc@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Message-ID: <20250215011437.1203084-5-seanjc@google.com> Subject: [PATCH v2 4/5] KVM: x86/xen: Bury xen_hvm_config behind CONFIG_KVM_XEN=y From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joao Martins , David Woodhouse Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that all references to kvm_vcpu_arch.xen_hvm_config are wrapped with CONFIG_KVM_XEN #ifdefs, bury the field itself behind CONFIG_KVM_XEN=3Dy. No functional change intended. Reviewed-by: David Woodhouse Reviewed-by: Paul Durrant Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index b15cde0a9b5c..f31fca4c4968 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1410,8 +1410,6 @@ struct kvm_arch { struct delayed_work kvmclock_update_work; struct delayed_work kvmclock_sync_work; =20 - struct kvm_xen_hvm_config xen_hvm_config; - /* reads protected by irq_srcu, writes by irq_lock */ struct hlist_head mask_notifier_list; =20 @@ -1421,6 +1419,7 @@ struct kvm_arch { =20 #ifdef CONFIG_KVM_XEN struct kvm_xen xen; + struct kvm_xen_hvm_config xen_hvm_config; #endif =20 bool backwards_tsc_observed; --=20 2.48.1.601.g30ceb7b040-goog From nobody Fri Dec 19 16:53:36 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 5A7DB7DA7F for ; Sat, 15 Feb 2025 01:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582089; cv=none; b=JjkYrFuLGxuQTYx8dDUlaVD/J5lUwqEBlEoJ8a4S+ymf9ZkhRsq3KxdoMq69CVCafKtYf7bYlUmwNnbRxder3y4jdNh4tG7RID1WzakDX3GIlHXAHQ+LBYk2rEKUDzxOiqeaQde+CSEmI990f6aESF28spb/ZOiI1p9TIlj7dvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739582089; c=relaxed/simple; bh=6YMwVl8AMR0ctcpdu9pVBh/LS5yL2fIICMQwk/b3AWI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=m2Pzmrig4LB6FCH7n1up88O24JIRBTnh5prD/VNb5DjkD6yMNDlqcZzT5Bti3rQkYNE/k3IlJ+mfafF28ffdKUs/WicT7HsdploQNLdiysu+xr2PzvmUIQZ6VYD+iWIdqNwxNO1DXPo9VF5BR55JqowyHOQ3YH4EfYR7rV16dXM= 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=zEkUcLjQ; arc=none smtp.client-ip=209.85.216.74 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="zEkUcLjQ" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2fc1a4c150bso5359679a91.2 for ; Fri, 14 Feb 2025 17:14:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739582088; x=1740186888; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=kBlYOtEQWFFXQTOIKSQhEAVmxuq5bgSQmqN3gKZONVw=; b=zEkUcLjQXq6+yzByxqLRisg6FrqGcDZ8A0zOiMP71/0gdl4tuEV//9HW3GSRUf03u/ 93ojFUVWD/SbwY0HA+2zs8EOCyhTqbVXaiIF6piswIilKTVihbAu3cs08igh55KMsgkL BU3KXrqxv1klykpnj5FTMCASHXF5bawtyD1SpLfjB2jpNxQdtVlm72GHV3WyDQJlPhrv 3TonhrKjTz/OgdvfsO2PMe7woDAk+9hdm9kplw6oxJUUA5QsXhK8Xmm/RJ9OCqOwLcHR Hi3TZuXtWgixmEyeX9sp+EUgXoFyvSwJxjViu5xAu7f27ExMUuRMZvll5X3UK8VFkG2T aINw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739582088; x=1740186888; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kBlYOtEQWFFXQTOIKSQhEAVmxuq5bgSQmqN3gKZONVw=; b=WqcbOTeOnf1srhQDHo2VMXdVIzA4nH+D1qdl2QADnboL+Q3CbF+ZI76zobtp5I59D1 ceh/JthMLcN6xEa1g1lfG4QckW7m3rheZwtvtX77rmgFFw3Ap9HeNROwYk2Pc1mZCDNS Sj2GN3CZ9gdJWynwrMPe2HszSoynmnvMgfrAlPwcd5iS9pSgDNjt5xs4J0/wdP/QKjZk JOOU7VElIbgdImbWudjzyPayfsWXdxf9um9uq23dc2y/mI+T9rHGCae+QtTSWYJOWNBe 1714g0LDShzstgCqq+JAMCSz3HmKVt8Ezwg+4m8oMHsm6Ls02ugqBns19Lw54g60Br1u aChA== X-Forwarded-Encrypted: i=1; AJvYcCUhEIxQ82JS9WnZYtTVS+kGnTkgByXKeXRnp/CxT1l7tFh7ec7aOWKBY+DBy95pV4qwXHPuzf+iSkVDgG8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9UUHq7y6NfbNpOgw0jzYpMbfU1Etdz8b5J81p8SBvxDcrF07J afLFAsxaKStFKuRjtVu04HEzoSUU21DOPt8Mt70cX6c47Q6Q371aX5odyLtFNhy2RcQGbHRkigl KCA== X-Google-Smtp-Source: AGHT+IF/7aRcBkLI8VIoVFuxAUKTg7k+HuZU+C7mws5yenQi6hifj9Ro1N+YIqcNVFadqp5WH7EEULpvZl4= X-Received: from pjbeu15.prod.google.com ([2002:a17:90a:f94f:b0:2fc:1eb0:5743]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:38c6:b0:2ef:33a4:ae6e with SMTP id 98e67ed59e1d1-2fc40f10876mr2175339a91.12.1739582087929; Fri, 14 Feb 2025 17:14:47 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 14 Feb 2025 17:14:37 -0800 In-Reply-To: <20250215011437.1203084-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250215011437.1203084-1-seanjc@google.com> X-Mailer: git-send-email 2.48.1.601.g30ceb7b040-goog Message-ID: <20250215011437.1203084-6-seanjc@google.com> Subject: [PATCH v2 5/5] KVM: x86/xen: Move kvm_xen_hvm_config field into kvm_xen From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joao Martins , David Woodhouse Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that all KVM usage of the Xen HVM config information is buried behind CONFIG_KVM_XEN=3Dy, move the per-VM kvm_xen_hvm_config field out of kvm_arch and into kvm_xen. No functional change intended. Reviewed-by: David Woodhouse Reviewed-by: Paul Durrant Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/x86.c | 2 +- arch/x86/kvm/xen.c | 20 ++++++++++---------- arch/x86/kvm/xen.h | 6 +++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index f31fca4c4968..9df725e528b1 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1188,6 +1188,8 @@ struct kvm_xen { struct gfn_to_pfn_cache shinfo_cache; struct idr evtchn_ports; unsigned long poll_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)]; + + struct kvm_xen_hvm_config hvm_config; }; #endif =20 @@ -1419,7 +1421,6 @@ struct kvm_arch { =20 #ifdef CONFIG_KVM_XEN struct kvm_xen xen; - struct kvm_xen_hvm_config xen_hvm_config; #endif =20 bool backwards_tsc_observed; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 12c60adb7349..f97d4d435e7f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3188,7 +3188,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) * problems if they observe PVCLOCK_TSC_STABLE_BIT in the pvclock flags. */ bool xen_pvclock_tsc_unstable =3D - ka->xen_hvm_config.flags & KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE; + ka->xen.hvm_config.flags & KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE; #endif =20 kernel_ns =3D 0; diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index 5b94825001a7..8aef7cd24349 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1280,10 +1280,10 @@ int kvm_xen_write_hypercall_page(struct kvm_vcpu *v= cpu, u64 data) * Note, truncation is a non-issue as 'lm' is guaranteed to be * false for a 32-bit kernel, i.e. when hva_t is only 4 bytes. */ - hva_t blob_addr =3D lm ? kvm->arch.xen_hvm_config.blob_addr_64 - : kvm->arch.xen_hvm_config.blob_addr_32; - u8 blob_size =3D lm ? kvm->arch.xen_hvm_config.blob_size_64 - : kvm->arch.xen_hvm_config.blob_size_32; + hva_t blob_addr =3D lm ? kvm->arch.xen.hvm_config.blob_addr_64 + : kvm->arch.xen.hvm_config.blob_addr_32; + u8 blob_size =3D lm ? kvm->arch.xen.hvm_config.blob_size_64 + : kvm->arch.xen.hvm_config.blob_size_32; u8 *page; int ret; =20 @@ -1335,13 +1335,13 @@ int kvm_xen_hvm_config(struct kvm *kvm, struct kvm_= xen_hvm_config *xhc) =20 mutex_lock(&kvm->arch.xen.xen_lock); =20 - if (xhc->msr && !kvm->arch.xen_hvm_config.msr) + if (xhc->msr && !kvm->arch.xen.hvm_config.msr) static_branch_inc(&kvm_xen_enabled.key); - else if (!xhc->msr && kvm->arch.xen_hvm_config.msr) + else if (!xhc->msr && kvm->arch.xen.hvm_config.msr) static_branch_slow_dec_deferred(&kvm_xen_enabled); =20 - old_flags =3D kvm->arch.xen_hvm_config.flags; - memcpy(&kvm->arch.xen_hvm_config, xhc, sizeof(*xhc)); + old_flags =3D kvm->arch.xen.hvm_config.flags; + memcpy(&kvm->arch.xen.hvm_config, xhc, sizeof(*xhc)); =20 mutex_unlock(&kvm->arch.xen.xen_lock); =20 @@ -1422,7 +1422,7 @@ static bool kvm_xen_schedop_poll(struct kvm_vcpu *vcp= u, bool longmode, int i; =20 if (!lapic_in_kernel(vcpu) || - !(vcpu->kvm->arch.xen_hvm_config.flags & KVM_XEN_HVM_CONFIG_EVTCHN_SE= ND)) + !(vcpu->kvm->arch.xen.hvm_config.flags & KVM_XEN_HVM_CONFIG_EVTCHN_SE= ND)) return false; =20 if (IS_ENABLED(CONFIG_64BIT) && !longmode) { @@ -2300,6 +2300,6 @@ void kvm_xen_destroy_vm(struct kvm *kvm) } idr_destroy(&kvm->arch.xen.evtchn_ports); =20 - if (kvm->arch.xen_hvm_config.msr) + if (kvm->arch.xen.hvm_config.msr) static_branch_slow_dec_deferred(&kvm_xen_enabled); } diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h index 1e3a913dfb94..d191103d8163 100644 --- a/arch/x86/kvm/xen.h +++ b/arch/x86/kvm/xen.h @@ -53,7 +53,7 @@ static inline void kvm_xen_sw_enable_lapic(struct kvm_vcp= u *vcpu) static inline bool kvm_xen_msr_enabled(struct kvm *kvm) { return static_branch_unlikely(&kvm_xen_enabled.key) && - kvm->arch.xen_hvm_config.msr; + kvm->arch.xen.hvm_config.msr; } =20 static inline bool kvm_xen_is_hypercall_page_msr(struct kvm *kvm, u32 msr) @@ -61,13 +61,13 @@ static inline bool kvm_xen_is_hypercall_page_msr(struct= kvm *kvm, u32 msr) if (!static_branch_unlikely(&kvm_xen_enabled.key)) return false; =20 - return msr && msr =3D=3D kvm->arch.xen_hvm_config.msr; + return msr && msr =3D=3D kvm->arch.xen.hvm_config.msr; } =20 static inline bool kvm_xen_hypercall_enabled(struct kvm *kvm) { return static_branch_unlikely(&kvm_xen_enabled.key) && - (kvm->arch.xen_hvm_config.flags & + (kvm->arch.xen.hvm_config.flags & KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL); } =20 --=20 2.48.1.601.g30ceb7b040-goog