From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 29DC02D0C7D for ; Thu, 13 Nov 2025 21:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763067774; cv=none; b=V3/y2sALVZf7X5dZrySHrPFkJ3Mplon+V67gbcE65wC5XQHM9SC4z8Ubwr/+6UVz+UfcVPzKDJjDshdn1WH3hxW+lf0q4FPFBKZv/wR7hQdcAdttcopKUE7j3gDi0wCJP4NOjZY4DmlQdopgHLg5TpAx9nY62xjt2tpKh7Yubvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763067774; c=relaxed/simple; bh=JJMmcUtZJp8Q17nld1BqpwgAO2U2Da66BAIpwFh59GE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IoD55KSZ555Fa38sLcH0ZCd+M4VYlDdByoV6nr77wyIkR0BQ1sObVMTOKu1W6V5B9n4JrOeZ2G7WQ33P/tqCVYwUTVxWcapA9oXjc/kac+8gJASCmG9Bq7nPrff54F/pNxk6iU57ZUwVfWVQCbO9H2XQXzZfT90PP9I4KgPltc4= 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=pJgXktwd; arc=none smtp.client-ip=209.85.214.201 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="pJgXktwd" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2954d676f9dso10888325ad.0 for ; Thu, 13 Nov 2025 13:02:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763067771; x=1763672571; 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=a7uBxDd7R+0ljt93BFkiA/Yx0vDhWSjlZQEH3Y9tQqs=; b=pJgXktwdp6HrNeZBlKRTlyTwF56c66JASo7/qDcXW2VBYHpf2JWjaVVjWUjzHVAbBu wxniwqrEM9I0MQTX8FTTl/MfhoQH20/f8PQCftGdqYPqxc5jAdLGlCE65LR8SdZi7bqr 5eVHDE3uvjW7e2WUF9kuUYMQ1rc6RgEqMsYP23CqRNcBDsIFoLT0a41mZkufXwitf+Lb isKNoVy1o9xOjnlQP0gg72IzgbB3pCoZUBPGNOwms+bR54D8mm871PNb+Z9vMpXB672J ckzOv5ez9Po93rPWzo3Ejgm3jcfVzyv4EzsOMZa6/RjoZF/tsMBOlf719CFMjkPpeiV2 TWDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763067771; x=1763672571; 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=a7uBxDd7R+0ljt93BFkiA/Yx0vDhWSjlZQEH3Y9tQqs=; b=ccQxzf6R4SLW+XV6+KgSf+PPLphGQdXT3anvezPJLCplQOsbu5n1uOntT14nEVRDrT u//VJmk9gwAFTYHya1M1QlakbLc8TLMuKEo2TeuhmoJVXyZqO4XsUp8kQ9GU6HBr85n8 9pmTySTXeqwNJc/4wZgfrN6Ku6ztZQjS8E/w377eTVpNXgMJ34foOS1wxd5oEFOrYlpj ktTeKj032y2fA5JR+u8+MFuN3q+Wv5kDDDKYF8LbRIbNDf2bVD/znf1yYmNp6/BWjPqT jn8omkzvERp8NWQRlELAtqVRbI81jBjBf/mDtGcQ8pUUja1v6ZhnzHvtfP+Lqq+zYWCn nX/g== X-Forwarded-Encrypted: i=1; AJvYcCX6C0nXMorayhJduVK5NOvaF9Rvi3ypBU8qjkQMhYwutsi+omVhmxO0lN99gPEkocNutXTifPO3PKNDIy4=@vger.kernel.org X-Gm-Message-State: AOJu0Yytdj3xa76spxqi24uGItK9bKehD7t+p4AoizTbuTPjB83ileqj kRP3rSfS8F9oRRQKRvjUz0Jh0GayJqb0EoFZnlKs7Sp9hWkTxJyu26iIp8J1ArIGqSzKsNY228k kFdxFHw== X-Google-Smtp-Source: AGHT+IF8Q/p7fFdV9MiImezpF9mKOY/uB6kSCpqMVPn6O8zg7LXO9eBP9jm0kD68oKRw55JkZXnSS7LXjkM= X-Received: from plkn5.prod.google.com ([2002:a17:902:6a85:b0:295:1ab8:c43c]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1b10:b0:296:3f23:b93b with SMTP id d9443c01a7336-2986a6b7b8emr4493805ad.2.1763067771151; Thu, 13 Nov 2025 13:02:51 -0800 (PST) Date: Thu, 13 Nov 2025 13:02:49 -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: <20251108013601.902918-1-seanjc@google.com> Message-ID: Subject: Re: [PATCH] KVM: x86: Allocate/free user_return_msrs at kvm.ko (un)loading time From: Sean Christopherson To: Chao Gao Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Mon, Nov 10, 2025, Chao Gao wrote: > >-static int kvm_init_user_return_msrs(void) > >+static void kvm_destroy_user_return_msrs(void) > > { > >- user_return_msrs = alloc_percpu(struct kvm_user_return_msrs); > >- if (!user_return_msrs) { > >- pr_err("failed to allocate percpu user_return_msrs\n"); > >- return -ENOMEM; > >- } > >+ int cpu; > >+ > >+ for_each_possible_cpu(cpu) > >+ WARN_ON_ONCE(per_cpu(user_return_msrs, cpu).registered); > > Could this warning be triggered if the forced shutdown path didn't > unregister the user return callback (i.e., with the patch [*] applied), > and then vendor modules got unloaded immediately after the forced shutdown > (before the CPU exits to the userspace)? Probably? But that's more of a feature than a bug, e.g. gives the (privileged!) user the heads up of how exactly they broke their system when they forced a reboot. I'd prefer not to condition it on e.g. !kvm_rebooting unless it's truly necessary, because it's "just" a WARN, i.e. shouldn't crash the system. > [*]: https://lore.kernel.org/kvm/20251030191528.3380553-4-seanjc@google.com/