From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 2EE9A284881 for ; Mon, 24 Nov 2025 14:45:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995528; cv=none; b=JwysDCdFyCiFadHnInU3DEZTktV5AJwm0s8ec7xDHxde8VPppBdL7S+EH5O5bUDcHi5FrogCQQ3lr2luu2XmxiQloJU9LCgEw2PyqrwAfS43kboAivKkdqRL03adZ7pXOC2YqLVNRXooTE3iQ9CISzA+9hLKmXdUZDwvFvBjT3I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995528; c=relaxed/simple; bh=Uj44h1HrNeevutUYxz9ybp04EuNUAMx5gjE4N04k2k8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YbIwHXvgsiqRJcsDSriW/X1WnAU8w6USdZOiBitWjC5kBQrN4MK7YLi/KEATRVNyuVz55IleBPL/3P3J4tfHaW8YbHUN2DF64ieTvQpEGLZ9ZBadrn1B6wJUED0d0EQVLNJINprYtxTNVvlzc6A1kSPMHsPZExKwLKDNt31olys= 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=Bi2UGPMz; arc=none smtp.client-ip=209.85.216.73 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="Bi2UGPMz" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-345b4f2a8e8so8546731a91.1 for ; Mon, 24 Nov 2025 06:45:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763995526; x=1764600326; 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=9fE7+f2OWBnj05HwKN8MoBtaOwH50J/pRBHbgVyU8iw=; b=Bi2UGPMzNKPQyosL9nrTyx751Kp+Hyi8A2IZdiE5Npqmz5EOaUOXEq2fEph3vqWt5T DGCCia8Ii7+Chir1QHcnC98AJIpuGB9xFUQSFQBq1AtMHIxO9RFkIR0s04b3ep03uewH K8/XAc+YPfh0eNgjfZH404OaClALqOtnkVLkS4TPAoVni2nJQOak0qJjcelbOhaavb6q E+/ffWD01acFem1HRfUxbTbNaDlP3u1fARgW7FCwpuGDM7xJ8GPRYvESu5O57cusubfH an8hebG+oH73STi5e3AK8G3hNSiIvYVcVIaP16iQEMPFH+nCrxB8afxQSeMjiFhUXuY9 NZUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763995526; x=1764600326; 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=9fE7+f2OWBnj05HwKN8MoBtaOwH50J/pRBHbgVyU8iw=; b=rsj8VtYvS2rz1ShKtoZKgy7I6I7bfVzy/4TUGPeyxHMWO7kdSZ3aleK3FU2XSp0QLD b+5ed6mlI2RZi6ipIoFArRVGLo/1YzFRnqR0KZJyik8VQ9fr/vmk8PBmqzaGeQmhRipu TXxScrYnw30dX+8QMfeLsYOb/MGvKTu6Sj91QVZSTBm6pxBuaUJxRoM0k3VPMjQ6nky4 RxrAGlPDpCjXscfWuSSCjND05/yk8VIIpQxo4ELLij/Uh7SoUlCQCyqZDxZLyB4Mf24/ vmZf857UeVddCSuqb843DIQ5dLKu3N+CEMlILwkc709qh0/yuRZQ5e02Y9yx0kBp44o5 ap+w== X-Forwarded-Encrypted: i=1; AJvYcCV8TvVeJ8aJ0AbezqMzf0ievvl9686oQUuoLcl7tEGoscpvnjVJTMtMYf3ogMsIhHQ5gu0VLbCRNKeOsAI=@vger.kernel.org X-Gm-Message-State: AOJu0YzBOv/uaIdjsII3F5obt8WzC2vhwHIw2PFqCZzRZawvFsplfsp9 D4346bpdbuN4T144X9XiD1LA4YIa8aiyj3e7MBeyNzS/1pwFqL6XEnAcmHn0c7/dmB9EUYCGVkd G8udC1Q== X-Google-Smtp-Source: AGHT+IHC7vs0COC7XQk5p8pgxTdNB88Vgg41x04P+492u7N93D06kfvulbK47vib5dZ65Hy966JYSwOSU/A= X-Received: from pjup18.prod.google.com ([2002:a17:90a:d312:b0:340:3e18:b5c]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2d4f:b0:341:c964:126c with SMTP id 98e67ed59e1d1-34733f5b790mr10339364a91.34.1763995526293; Mon, 24 Nov 2025 06:45:26 -0800 (PST) Date: Mon, 24 Nov 2025 06:45:22 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251121193204.952988-1-yosry.ahmed@linux.dev> <20251121193204.952988-2-yosry.ahmed@linux.dev> Message-ID: Subject: Re: [PATCH 1/3] KVM: x86: Add CR3 to guest debug info From: Sean Christopherson To: Yosry Ahmed Cc: Paolo Bonzini , Ken Hofsass , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Fri, Nov 21, 2025, Yosry Ahmed wrote: > On Fri, Nov 21, 2025 at 01:01:40PM -0800, Sean Christopherson wrote: > > On Fri, Nov 21, 2025, Yosry Ahmed wrote: > > KVM already provides kvm_run.kvm_valid_regs to let userspace grab register state > > on exit to userspace. If userspace is debugging, why not simply save all regs on > > exit? > > > > If the answer is "because it slows down all other exits", then I would much rather > > give userspace the ability to conditionally save registers based on the exit reason, > > e.g. something like this (completely untested, no CAP, etc.) > > I like this approach conceptually, but I think it's an overkill for this > use case tbh. Especially the memory usage, that's 1K per vCPU for the > bitmap. I know it can be smaller, but probably not small either because > it will be a problem if we run out of bits. > > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > > index 52f6000ab020..452805c1337b 100644 > > --- a/include/uapi/linux/kvm.h > > +++ b/include/uapi/linux/kvm.h > > @@ -494,8 +494,12 @@ struct kvm_run { > > struct kvm_sync_regs regs; > > char padding[SYNC_REGS_SIZE_BYTES]; > > } s; > > + > > + __u64 kvm_save_regs_on_exit[16]; Heh, check your math. It's 1024 bits, 128 bytes. Reserving space for 1024 exits is likely extreme overkill given that KVM is sitting at 40 exits after ~18 years, so as you say we could cut that down significantly depending on how willing we are to risk having to add kvm_save_regs_on_exit2 in the future.