From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D101F35949; Tue, 30 Sep 2025 19:20:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759260043; cv=none; b=kUhWBzVghMK0oHn09pk6U653wW2fFAsgXecUUzcPz8odRCoP4r53BC1aZBqStha3mewqH37eLT0NlRY/+T+PZosYYkZ2Hq+59bVdgkI1bmE/K5nivqfFdHLnz/r7CUEUPbYd1gZ0hqBSVKihPhpDo4UX6stWhZf25mto0MRz3+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759260043; c=relaxed/simple; bh=SvJ8S7Nw/fPta0kTc9ASSeJSDJulLZWtqNWEtdEqeps=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FZ30aCDXXm71T0+PMo9D/UnTUf4QJwKoZD/fwYcc5Pd1D4mn+poA12C1C+H9dKFilqgh1Jl4imccpZlnJmfpib9Gmnz/eF5aGZXpGmznNdH2DxHfu+6im9Mu0mXRqBRepJjQd3+yC9m0UlYRMm7qMQ1v05UL4ok5W+RMkGuwGns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=KmHeNLZj; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="KmHeNLZj" Received: from [IPV6:2601:646:8081:9484:3373:e8bd:aaa4:7c23] ([IPv6:2601:646:8081:9484:3373:e8bd:aaa4:7c23]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 58UJJc0q376069 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Tue, 30 Sep 2025 12:19:38 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 58UJJc0q376069 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025092201; t=1759259981; bh=5jKsWr8QEv1dE0BHGjK4jG5jy4dVCkN+HP+b8pZLYWY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=KmHeNLZj/n0P3Bx95LFzhVuxLXrHMsWLMMJ2Gm4H8FNamSlw/ykdibwr0KiTsB1Hx kimmmjaE4PQNu82809DGZ+bXQB5PtFK+1BIkP2kit+wX/G9oZjCTGQQ4NBn3eyeroN igAJ5wylIhFE9616RLBxQ4fa1M/81mz3016d0y5QrZzka0FJXVai2ABAi7s6qurIZU UCt7L6g9U8v2bHT5kR3usV/nGI4JUG2MRe34f5yvbCfc1Wc8a+J7TpEqXyLIfbRGUg AzbRtlbso5/anwJIMETPoxFJcMs4aRnGHHmG/oIvBJHSwcgPCKq+EsfPpQlRB7rZB1 WCrrEfyQwfYwQ== Message-ID: <1412c7a5-8961-4949-b09e-7b9d080ce9bf@zytor.com> Date: Tue, 30 Sep 2025 12:19:33 -0700 Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 00/12] x86/msr: Inline rdmsr/wrmsr instructions To: Juergen Gross , linux-kernel@vger.kernel.org, x86@kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, llvm@lists.linux.dev Cc: xin@zytor.com, "Kirill A. Shutemov" , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Sean Christopherson , Paolo Bonzini , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Vitaly Kuznetsov , Boris Ostrovsky , xen-devel@lists.xenproject.org, Ajay Kaher , Alexey Makhalov , Broadcom internal kernel review list , Andy Lutomirski , Peter Zijlstra , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt References: <20250930070356.30695-1-jgross@suse.com> Content-Language: en-US, sv-SE From: "H. Peter Anvin" In-Reply-To: <20250930070356.30695-1-jgross@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2025-09-30 00:03, Juergen Gross wrote: > When building a kernel with CONFIG_PARAVIRT_XXL the paravirt > infrastructure will always use functions for reading or writing MSRs, > even when running on bare metal. > > Switch to inline RDMSR/WRMSR instructions in this case, reducing the > paravirt overhead. > > In order to make this less intrusive, some further reorganization of > the MSR access helpers is done in the first 5 patches. > > The next 5 patches are converting the non-paravirt case to use direct > inlining of the MSR access instructions, including the WRMSRNS > instruction and the immediate variants of RDMSR and WRMSR if possible. > > Patch 11 removes the PV hooks for MSR accesses and implements the > Xen PV cases via calls depending on X86_FEATURE_XENPV, which results > in runtime patching those calls away for the non-XenPV case. > > Patch 12 is a final little cleanup patch. > > This series has been tested to work with Xen PV and on bare metal. > > This series is inspired by Xin Li, who used a similar approach, but > (in my opinion) with some flaws. Originally I thought it should be > possible to use the paravirt infrastructure, but this turned out to be > rather complicated, especially for the Xen PV case in the *_safe() > variants of the MSR access functions. > Looks good to me. (I'm not at all surprised that paravirt_ops didn't do the job. Both I and Xin had come to the same conclusion.) Reviewed-by: H. Peter Anvin (Intel)