From nobody Fri Oct 31 03:41:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1755290514; cv=none; d=zohomail.com; s=zohoarc; b=NU4zUQQuWkky5frKrLmwk7oREYJfY9tsXMBRsRcWAZuW00ZE3aFl1cV2kQk/WdgJliT75OLRGBPWyKxYkelKaNjvjqxSWYAJgU4cKnZlNQTm1ew95e0s1A9Z41GSFYkT1YvVFqWMY2hmpcLgAOTTELDLNzhmhKw/Ty+IAZqgWqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755290514; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5l8iC7hfjMIumK90MTT4QYT+fq6ZtsDyp8BT4xY81Ws=; b=Zlx2G6YHnArttf03uaaIzwuH8Ips2Fq/dhHh+fetnMQismmC4GhRPF9cjL9I6boCjHwdO6LANpUbw22XLGC7/tBPa35GlclrnhVloAbK4hRESLJSk5UnhMxyHP7z5Bzs3WrgrnnqEzklsZJxhha8ioa+PdyzIpGxWT0JdLZgfBw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1755290514629685.9312071703273; Fri, 15 Aug 2025 13:41:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1083898.1443433 (Exim 4.92) (envelope-from ) id 1un1F3-0008Dy-Lf; Fri, 15 Aug 2025 20:41:37 +0000 Received: by outflank-mailman (output) from mailman id 1083898.1443433; Fri, 15 Aug 2025 20:41:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1un1F2-00088l-S3; Fri, 15 Aug 2025 20:41:36 +0000 Received: by outflank-mailman (input) for mailman id 1083898; Fri, 15 Aug 2025 20:41:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1un1Ez-0005E7-Jz for xen-devel@lists.xenproject.org; Fri, 15 Aug 2025 20:41:33 +0000 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [2a00:1450:4864:20::32c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3a0fcd2e-7a18-11f0-a328-13f23c93f187; Fri, 15 Aug 2025 22:41:32 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-45a1b00797dso14310255e9.0 for ; Fri, 15 Aug 2025 13:41:32 -0700 (PDT) Received: from localhost.localdomain (host-195-149-20-212.as13285.net. [195.149.20.212]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3bb5d089e07sm3153924f8f.0.2025.08.15.13.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Aug 2025 13:41:30 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3a0fcd2e-7a18-11f0-a328-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1755290491; x=1755895291; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5l8iC7hfjMIumK90MTT4QYT+fq6ZtsDyp8BT4xY81Ws=; b=QgUKC5CwmPiTcmGUKQj4TFX97xJEJIrTv+BHwTwCnhuNMbQTHl1ZS3c5Dfxhdbaeo0 8e1NMVLNvcEE/8G95mbintsRUbaHClebKRjn3CuS2WYeYZECKR5D1QzHVj+z6XUbbWPz ZlPwKiFu6s6y0EAAQDWjDvUexT7WKAk4+PFdY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755290491; x=1755895291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5l8iC7hfjMIumK90MTT4QYT+fq6ZtsDyp8BT4xY81Ws=; b=AyjMgcLktLjUsx3yJetjn3xCx0FCLLIg5C4FPEI740u6/mVIgT6nlrQlwAPkM++MHR +kg9dGWa6Hn9lUgbDpCz40rCTg1KPovFllwit29AL6C6YVvI3Puj+MBpLSUIhIUoLZQA MO0e7bGom3oXqdoctan/WNmDEryfFUIZJgP4uknSOeUlkYccqZKfgvfZB4LLi/w4pu1h RD2DM4danEB6DjPwdiodcfnnSC/qZCvpCcHCgcEzgxIwZzkc0w913ar6DZz98yOv+PmW 555OIxiwmS3ksiGBZQc9b26fd/Gjo14s6t3P99rscIImdgl83D8PVJdM0Q4OZ7Z/HVdQ icGQ== X-Gm-Message-State: AOJu0YxnhgQAR5LzzoJHyZp6Vuk4U42UcR0zQQ6x8gN5QQ5NSxscFO+5 i0ziSYXng0/OnyvzIhMwgUEIjeNylBOzoSdIckcnnSODKJrNS105x8a8q+TI+81i4+xssszf3F/ os5gb X-Gm-Gg: ASbGncu9CAG5i96IyEzfN7I8aM0BNSHdpfL9OI7o9wWlO3pUT6Tp91+z9oQ8LY4DCVl PcH5t0Ksobp25f6fwV2qssii//TP8nU7DnWT6UHnzB5rWm6TdH3jG1OK4xOopzgZ20xbY1rPzHJ ed1n/nK5k2xlOecaVw1HGkXwAlsi8qu2XgmyKIxcUCbltaoTipTFAKjgdPkvaOnkImGbI9qrp0F LTFJzsHZ3x7104jbcLHXRrXAHCuPeBc8zX7/k1Ti2dOC8p9BFKXfmJ3bHuewIbFcCcmJZiu5vZh yfrZe0+T0QKNXfr3z4ShrUlm50g9Q/jHmzZnmVjFySx08eOETgwMxsIvqNVm5WzxcuFnwcOR7dT ASofD2IZq1DpkBV3xLEyY39QurqeuULeDuG5wRXnD0TLAcuSJYaLq5YzPpRyq/YBlOETic2KUfU OW X-Google-Smtp-Source: AGHT+IGLKcxsTFD/74Q1iwVsGiS+q0qhl5kyjKoENcYh0fT3yViCJ70DCGmKJRr8XyDGkjzzso3jDw== X-Received: by 2002:a05:600c:1e03:b0:458:bfb1:1fb6 with SMTP id 5b1f17b1804b1-45a21d44a9amr32589075e9.2.1755290491196; Fri, 15 Aug 2025 13:41:31 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 14/16] x86/fsgsbase: Split out __{rd,wr}gskern() helpers Date: Fri, 15 Aug 2025 21:41:15 +0100 Message-Id: <20250815204117.3312742-15-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250815204117.3312742-1-andrew.cooper3@citrix.com> References: <20250815204117.3312742-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1755290515854124100 Right now they're inline in {read,write}_gs_shadow(), but we're going to ne= ed to use these elsewhere to support FRED. No functional change. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/include/asm/fsgsbase.h | 36 ++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/include/asm/fsgsbase.h b/xen/arch/x86/include/asm= /fsgsbase.h index 03e6a85d31ce..90d116f3bb54 100644 --- a/xen/arch/x86/include/asm/fsgsbase.h +++ b/xen/arch/x86/include/asm/fsgsbase.h @@ -32,6 +32,17 @@ static inline unsigned long __rdgsbase(void) return base; } =20 +static inline unsigned long __rdgskern(void) +{ + unsigned long base; + + asm_inline volatile ( "swapgs\n\t" + "rdgsbase %0\n\t" + "swapgs" : "=3Dr" (base) ); + + return base; +} + static inline void __wrfsbase(unsigned long base) { asm volatile ( "wrfsbase %0" :: "r" (base) ); @@ -42,6 +53,14 @@ static inline void __wrgsbase(unsigned long base) asm volatile ( "wrgsbase %0" :: "r" (base) ); } =20 +static inline void __wrgskern(unsigned long base) +{ + asm_inline volatile ( "swapgs\n\t" + "wrgsbase %0\n\t" + "swapgs" + :: "r" (base) ); +} + static inline unsigned long read_fs_base(void) { unsigned long base; @@ -71,13 +90,9 @@ static inline unsigned long read_gs_shadow(void) unsigned long base; =20 if ( read_cr4() & X86_CR4_FSGSBASE ) - { - asm volatile ( "swapgs" ); - base =3D __rdgsbase(); - asm volatile ( "swapgs" ); - } - else - rdmsrl(MSR_SHADOW_GS_BASE, base); + return __rdgskern(); + + rdmsrl(MSR_SHADOW_GS_BASE, base); =20 return base; } @@ -101,12 +116,7 @@ static inline void write_gs_base(unsigned long base) static inline void write_gs_shadow(unsigned long base) { if ( read_cr4() & X86_CR4_FSGSBASE ) - { - asm volatile ( "swapgs\n\t" - "wrgsbase %0\n\t" - "swapgs" - :: "r" (base) ); - } + __wrgskern(base); else wrmsrl(MSR_SHADOW_GS_BASE, base); } --=20 2.39.5