[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFULd4Y3VvqNS8VEvw0ObnqnVDtsC-q3kDEnyc070=gZ9oehgg@mail.gmail.com>
Date: Fri, 16 May 2025 09:51:50 +0200
From: Uros Bizjak <ubizjak@...il.com>
To: Chao Gao <chao.gao@...el.com>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
tglx@...utronix.de, dave.hansen@...el.com, seanjc@...gle.com,
pbonzini@...hat.com, peterz@...radead.org, rick.p.edgecombe@...el.com,
weijiang.yang@...el.com, john.allen@....com, bp@...en8.de,
chang.seok.bae@...el.com, xin3.li@...el.com,
Aruna Ramakrishna <aruna.ramakrishna@...cle.com>, Dave Hansen <dave.hansen@...ux.intel.com>,
Eric Biggers <ebiggers@...gle.com>, "H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
Kees Cook <kees@...nel.org>, Maxim Levitsky <mlevitsk@...hat.com>,
Mitchell Levy <levymitchell0@...il.com>, Nikolay Borisov <nik.borisov@...e.com>,
Oleg Nesterov <oleg@...hat.com>, Samuel Holland <samuel.holland@...ive.com>,
Sohil Mehta <sohil.mehta@...el.com>, Stanislav Spassov <stanspas@...zon.de>,
Vignesh Balasubramanian <vigbalas@....com>, Zhao Liu <zhao1.liu@...el.com>
Subject: Re: [PATCH v7 0/6] Introduce CET supervisor state support
On Mon, May 12, 2025 at 10:57 AM Chao Gao <chao.gao@...el.com> wrote:
>
> Dear maintainers and reviewers,
>
> I kindly request your consideration for merging this series. Most of
> patches have received Reviewed-by/Acked-by tags.
>
> Thanks Chang, Rick, Xin, Sean and Dave for their help with this series.
>
> == Changelog ==
> v6->v7:
> - Collect reviews from Rick
> - Tweak __fpstate_reset() to handle guest fpstate rather than adding a
> guest-specific reset function (Sean & Dave)
> - Fold xfd initialization into __fpstate_reset() (Sean)
> - v6: https://lore.kernel.org/all/20250506093740.2864458-1-chao.gao@intel.com/
>
> == Background ==
>
> CET defines two register states: CET user, which includes user-mode control
> registers, and CET supervisor, which consists of shadow-stack pointers for
> privilege levels 0-2.
>
> Current kernel disables shadow stacks in kernel mode, making the CET
> supervisor state unused and eliminating the need for context switching.
>
> == Problem ==
>
> To virtualize CET for guests, KVM must accurately emulate hardware
> behavior. A key challenge arises because there is no CPUID flag to indicate
> that shadow stack is supported only in user mode. Therefore, KVM cannot
> assume guests will not enable shadow stacks in kernel mode and must
> preserve the CET supervisor state of vCPUs.
>
> == Solution ==
>
> An initial proposal to manually save and restore CET supervisor states
> using raw RDMSR/WRMSR in KVM was rejected due to performance concerns and
> its impact on KVM's ABI. Instead, leveraging the kernel's FPU
> infrastructure for context switching was favored [1].
Dear Chao,
I wonder if the same approach can be used to optimize switching of
Intel PT configuration context. There was a patch series [1] posted
some time ago that showed substantial reduction of overhead when
switching Intel PT configuration context on VM-Entry/Exit using
XSAVES/XRSTORS instructions:
Manual save(rdmsr): ~334 cycles
Manual restore(wrmsr): ~1668 cycles
XSAVES insturction: ~124 cycles
XRSTORS instruction: ~378 cycles
[1] https://lore.kernel.org/lkml/1557995114-21629-1-git-send-email-luwei.kang@intel.com/
Best regards,
Uros.
Powered by blists - more mailing lists