From mboxrd@z Thu Jan 1 00:00:00 1970 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 2399338C43A for ; Thu, 2 Apr 2026 23:08:00 +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=1775171282; cv=none; b=DBW2EnTz8Hbeg9XbOcUMCJxH5Ewda2ngzDgsemE+AcvgbEt240UVYW6CjWKVxf3qi0zPDgdwlXJtzR9oZucm/6RpyglrzbOswP2d66623EQ5GihA6SiqiJEcH9lUl63Ws8crFsPr/bLZRM5RsuxKeiN4HB1LjaV1ORESvaI+zzI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775171282; c=relaxed/simple; bh=2PTm1I4LtYj1YB+Qns32E4oWyIFCWmAEJE74xx20oLU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oWXYY90Ao9p7GZ0DU//mbfufjCNBcDHnP+9BTEH+KSz5flBiE0cCQhWK76WiEYAlI7XQ69ZAEcSkzcgbSQdDUEdgzIBK7LJJnkxR7Rljr+zCwJPfDbut1GZXVQnd5+43k19H0Jn3Sm25cQdbz6FoPgcsGRE33CxSC+oWQ9CmdAs= 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=DvXfdrB4; 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="DvXfdrB4" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35dacc40f92so1055032a91.2 for ; Thu, 02 Apr 2026 16:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775171280; x=1775776080; 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=aLa0GVMX6VX9ga114RP9fzeLfvZH9WQjqCx0+9dg7Ds=; b=DvXfdrB4h3X1tkMmhy212XcHmOR8BOrai04/IpPALIC3i3neXTyihPSlY8W28j5oHv WqYljqEwYIcgsXwQZpZy20ARkhSsOQtv0uLjvXfXN9wBSDXuwRJ96BZvdF1p5WWFZyES S+UFdKuD0/GmqTVv/3nLHej55vXru72MWY/2bR50k7SW//o2NG/E9HrZbdvtqi4goQmz fWA7V0tk3aPyeBP/PzPdklJ6tn69s4lSnl26/cCMgLb+r6SCw37pHbQU4l+kbhtoXIdo 7C6yiNfoIUkWnRbExcQ6EqkrIxsvoI9TIHZRnYdceWJ1pKDxA1tjC19polUKipiNzOp3 SnQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775171280; x=1775776080; 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=aLa0GVMX6VX9ga114RP9fzeLfvZH9WQjqCx0+9dg7Ds=; b=eb3cgv5KafliHH5Ga64tcy5c6dvZXJmgrAFzgDo/JVtx9Vl1bVVrrGlFdCiqKy+QYM mIntaPLEN/LY7YsUCzFSoCfOAn/QNkyW+UzqiR5671Nfrj5fikz7c/lftuNLWQy0h1gp C9IdbijubFsv0H59e4BGKd4IibUuFGwSHBDpltuwUszOeXyXqjew3mW/46WA9f/6O67u TubcNR4FsVw5II3WJJeRYvzYSH0NAFcke7HKoQeG3bCneLf80c09+jySDaGYugfEdzmj rZFQ2cLpJxDVwg9i6F19TsSok7O6DCfPyjc+6/xnRZD34nU2tUYhZGAW9gqhi5Y7zkQ3 vdHQ== X-Forwarded-Encrypted: i=1; AJvYcCX9dkHTbLXnxN51FvaOe/1Z0xcEbd94IMVTCtFrUuiWqDJ8pmmEyc5Yy4tqdMYXRsWIwcky+aomt8aANY8=@vger.kernel.org X-Gm-Message-State: AOJu0YyrVLDIXWKKtiYfZqgoyuK1fkkyt1/0y//bmFWyVHKIZyUCp1zo nTO5ganhZkoLd6CRlONCeZgnlgXIdfK9u6fy44sTXbIISqS8E1YCpBmriWQxLyUxKI6xMlekuO5 29tN9sg== X-Received: from pjuw16.prod.google.com ([2002:a17:90a:d610:b0:35d:a8d7:ccda]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:e70f:b0:35b:e52a:6fe5 with SMTP id 98e67ed59e1d1-35de683b19amr592058a91.5.1775171280336; Thu, 02 Apr 2026 16:08:00 -0700 (PDT) Date: Thu, 2 Apr 2026 16:07:59 -0700 In-Reply-To: <3051c067-048e-4388-8c22-1e275d8d3b5a@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260311003346.2626238-1-seanjc@google.com> <7ec084f8-812e-42f2-8470-e416fa7ee848@redhat.com> <8853f8d5-57e6-4ea4-b9b5-8a0182d0d012@intel.com> <3051c067-048e-4388-8c22-1e275d8d3b5a@intel.com> Message-ID: Subject: Re: [PATCH 0/7] KVM: x86: APX reg prep work From: Sean Christopherson To: "Chang S. Bae" Cc: Paolo Bonzini , Kiryl Shutsemau , kvm@vger.kernel.org, x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Wed, Mar 25, 2026, Chang S. Bae wrote: > On 3/12/2026 10:47 AM, Sean Christopherson wrote: > > On Thu, Mar 12, 2026, Chang S. Bae wrote: > > > > > > However, that is sort of what-if scenarios at best. The host kernel still > > > manages EGPR context switching through XSAVE. Saving EGPRs into regs[] would > > > introduce an oddity to synchronize between two buffers: regs[] and > > > gfpu->fpstate, which looks like unnecessary complexity. > > No, this looks ugly. Sorry, you lost me. What looks ugly? > If guest EGPR state is saved in vcpu->arch.regs[], the APX area there isn't > necessary: > > When the KVM API exposes state in XSAVE format, the frontend can handle this > separately. Alongside uABI <-> guest fpstate copy functions, new copy > functions may deal with the state between uABI <-> VCPU cache. > > Further, one could think of exclusion as such: > > diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c > index 76153dfb58c9..5404f9399eea 100644 > --- a/arch/x86/kernel/fpu/xstate.c > +++ b/arch/x86/kernel/fpu/xstate.c > @@ -794,9 +794,10 @@ static u64 __init guest_default_mask(void) > { > /* > * Exclude dynamic features, which require userspace opt-in even > - * for KVM guests. > + * for KVM guests, and APX as extended general-purpose register > + * states are saved in the KVM cache separately. > */ > - return ~(u64)XFEATURE_MASK_USER_DYNAMIC; > + return ~((u64)XFEATURE_MASK_USER_DYNAMIC | XFEATURE_MASK_APX); > } > > But this default bitmask feeds into the permission bits: > > fpu->guest_perm.__state_perm = guest_default_cfg.features; > fpu->guest_perm.__state_size = guest_default_cfg.size; > > This policy looks clear and sensible: permission is granted only if space is > reserved to save the state. If there is a strong desire to save memory, I > think it should go through a more thorough review to revisit this policy. And I'm lost again.