From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 2E2F235F18B for ; Thu, 2 Apr 2026 23:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775171981; cv=none; b=b9lyBVpFIdG8HzhjNIP+vurEqQr69IAgoKUHeh1set7sI8A8UA5YteqZp1+AfxGolyoPVxI1SgzDbTNa2ARH7vzifZrbS0yiaAOJpUuSIgAEWtcK/p1iwawumWf/XBMzemMPu0LCCv3YXwmp5PPmDxgbY285cPBByw6VbrScBjc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775171981; c=relaxed/simple; bh=64WF9D/zEKwq1YYpyTovrgO/rjWkytAHL1xAfHFCask=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UwlhWoV+eGPkaxC5+MFiGSZBTUiPmGDuEqA11pYzNUJL7WCYRCEGBkIYdFf7yLO4gJz1NL8baQH3pkVsK1wMdH4SIUpzadEx83IR6uHHz8EbX4I8sxZFmvv5SGrQQi28eiEtOcjCwnC1BPmAhnjW9/+JWwuVejmy6bP6A3naAcs= 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=Vh6hGOnk; arc=none smtp.client-ip=209.85.215.202 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="Vh6hGOnk" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c76b06f37a7so528435a12.0 for ; Thu, 02 Apr 2026 16:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775171979; x=1775776779; 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=/t66izQLCHQ6s6AfRMkWgUrhQjqz/ggbzYq1LBRn2XE=; b=Vh6hGOnkgiopMqqqP3W7jNSy0LByG17WyQIs0HtSW5iFD6urvB2dUVVlkl/GCTiKQO 8Z9QOWccp3ZwCPKdbvCnJPTmt5Z0lUdJV4OHeNyekhv/OodonIZrSMmjCpJK6I8CsSYv KSzt7nB+e+XJoZ/Rtdvac+YZAvA1Ze9l6cICb1n7s3JReQ1am29X2sf+3i9wMC7YkV0Q hBc1hHICI8kKeeeX7RYtV6ntze3qUD2plIFCqBQucX37Ygsju3JhVevyAwpJLyvSzQV+ BfHhn467lT3sgh56npmSn0sPYxC0Ocv2K9ti1GlRNh1RZoS3HDWk9Btog5XrV3CW7i5o ZPhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775171979; x=1775776779; 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=/t66izQLCHQ6s6AfRMkWgUrhQjqz/ggbzYq1LBRn2XE=; b=AI8FsURGDs8BYLeh/OG3/Ag3qS6w69WLHP/poGSTrJcSsP0F2KckM8wBCulpotlxaM 29z1gdL8DNr/ngbEm0FrQXNqwmn9H40ItyjHMwAJ7Ksu8iY8H1jEYKcjf4+aMyZpnQFs BfS5gT4emabYvGXcupj4r6yOIdH0ye54M+glDDPCUXKDg9+UfAgwiKhNX/8CBmQ3lycQ AaAxssywgIaVO9htAZc1tssJFSq/hZGOYrPWXTaNVgcrYx7ekapp9UyB2VApkRN9ej2H kRlkVq6cloJ9Kkp1291pH3/4xWAeozgZQt7K2IxlMRlr3ykZ5AwGSp6S4EekxuWg8OWC ci9Q== X-Forwarded-Encrypted: i=1; AJvYcCVEr4kFauvIebosnUnduNdEv4CFwdTat5ft3yO93APSiwv/yRyCZwNVjo4aNXoJ9as2dD401gCw/q1S5RE=@vger.kernel.org X-Gm-Message-State: AOJu0YxCzatVIzLh/9ONva18M70g9IcLsUoi0hGabPMOJSATtlR1thIN kW7SHekvZ13F/vZG2f6EgNHpsdvqC/yArdwX3qKPUhjgbDnhXKAw0d3RDka1+h5zkk38sXKb3GQ uxOyKQg== X-Received: from pfbih23.prod.google.com ([2002:a05:6a00:8c17:b0:82c:e9cd:a73f]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3318:b0:829:9fa3:5c8b with SMTP id d2e1a72fcca58-82d0dbd53f8mr822637b3a.55.1775171979306; Thu, 02 Apr 2026 16:19:39 -0700 (PDT) Date: Thu, 2 Apr 2026 16:19:38 -0700 In-Reply-To: <7ec084f8-812e-42f2-8470-e416fa7ee848@redhat.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> Message-ID: Subject: Re: [PATCH 0/7] KVM: x86: APX reg prep work From: Sean Christopherson To: Paolo Bonzini Cc: Kiryl Shutsemau , kvm@vger.kernel.org, x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Chang S . Bae" Content-Type: text/plain; charset="us-ascii" On Wed, Mar 11, 2026, Paolo Bonzini wrote: > On 3/11/26 01:33, Sean Christopherson wrote: > > Clean up KVM's register tracking and storage in preparation for landing APX, > > which expands the maximum number of GPRs from 16 to 32. > > > > This is kinda sorta an RFC, as there are some very opinionated changes. I.e. > > if you dislike something, please speak up. > > > > My thought is to treat R16-R31 as much like other GPRs as possible (though > > maybe we don't need to expand regs[] as sketched out in the last patch?). > > The cleanups in patches 1-4 are nice. > > For APX specifically, in abstract it's nice to treat R16-R31 as much as > possible as regular GPRs. On the other hand, the extra 16 regs[] entries > would be more or less unused, the ugly switch statements wouldn't go away. Hmm, yeah, but only if XSAVE is the source of truth for guest R16-R31. Do we know what the compiler and/or kernel rules for using R16-R31 will be? E.g. if C code is allowed to use R16-R31 at will, then KVM will either need to swap R16-R31 in assembly, or annotate a pile of functions as "no_egpr" or whatever. At that point, my vote would be to use regs[] to track R16-R31 for KVM's purposes. IIUC, we could largely ignore XSAVE state at runtime and just ensure R16-R31 are copied to/from userspace as needed, same as we do for PKRU. If R16-R31 aren't generally available for C code, then how exactly is APX going to be used? Understanding the usage rules for R16-R31 seems fundamental to figuring what to do in KVM...