Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp283637lqb; Tue, 28 May 2024 15:51:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDC1wNtrtA4BJ/zPM25I5U8CxlNNbx0DgH1r7rf/p0Pefv3zLAUQViCAaD1aPy+M61A8u2FO7oIpqys+WsskQRvpFFLAkxS4u58ScCCg== X-Google-Smtp-Source: AGHT+IEBKU/OND/XvNUhOlN5EXV/Iwy/yGB1MeEo0bJvmN6zKnwSvB0SW3t+U2wZPuCi8PgytJq2 X-Received: by 2002:a05:6870:315:b0:24f:cf39:96a1 with SMTP id 586e51a60fabf-24fcf39be57mr14644158fac.12.1716936697423; Tue, 28 May 2024 15:51:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716936697; cv=pass; d=google.com; s=arc-20160816; b=jUQHv3HVglajVixGwrHN5rls2My8+wWsls3h1ks0Jd/Z0xkpZ65iLYrE3dSVwFJeLr eYWw0gHxxup8aKjwCsVvtgbBIXKNM4+vyirU7R6eNiIDZ4khbLmTxbPMtqa8rXIq0YH/ LKWD91npLUnqtPPOfyp81znqa6MIwXZXWJDlytfTu9RrBt69jGORBLhUvJZ9N+kr/ivH Ihg0UVzAmt4rVrTLehHD03NF4bdm6Ycwm4vtc6UAxrGKTyyPqydC06pxCEjAHT8dOBKv ORrqkdHyueaQ5FM1EcdKb4PCYZAN47au0htbl80/kWeBqg1hC6AHTLOGgsAR6OpqNaNM EQbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=UTOH3e/EfW+pY1lF/i3FXaQ/pSIJmaxop4NhBeQiFYU=; fh=lsPk9WUiJbOoMnFbp4R23BG0hcnxC69l6rtKizK5kYk=; b=W9cUFuIfpI4jqe0R5kRFNjvETEm2YxwzG7y6NosRTYvIEgwhNfa/Jxk+C6t/FBy2Uo M7T2qkuJyGGqenpkTgfGfC6J2N+VGFGZp7Z6zDLxhr5VS3ZmT6O3EsPS59Bo2tNqhIYt ZoSq+MaderdIvDm0IkQZgbS5eKkU/ZVJghxkXHmnzXywYpdW2uDsXPeMS5+XIpHwKOdv DUN3+9oyspSpPTyYfEQ8ht9GU6HpOte5T7mgt6PpfLFTTPHslhombwkkhIR/7bHucePO T08PjppTWL9bNYSIQr6bZ0Z2Zy3WkZJCSqo7QxXdoivbbpvClD5LYdNlAtgqH1DYDR7r 1rug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=L6idNiH3; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-193202-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193202-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-68221b73afbsi9406776a12.56.2024.05.28.15.51.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 15:51:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193202-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=L6idNiH3; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-193202-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193202-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 23E4E28398E for ; Tue, 28 May 2024 22:50:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A92A13E881; Tue, 28 May 2024 22:50:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L6idNiH3" Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.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 8A3C113E054 for ; Tue, 28 May 2024 22:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716936635; cv=none; b=DTISS8v0aHc3kQ4L7AIRAijRZj/70ZVzLOX8G+7hvmtz/jRbDdGrdmTrSiyD/EGD6dmicpmJlD2JjHys6m1aXfpKhLzgC08ufHSAArtvWBExdrDjF+1NqGWFMJ+Ms2UgALbghA9dUguuYDQabbCtPZvQ87X+FDbp4jYO8YaUnYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716936635; c=relaxed/simple; bh=gHbpfeSgkDfVxwkYwenrZjhrUWC3V/PMjbQDgO81FQk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dTjt5DMHOo+HELVI0LKyOJcc8egP2c2Sbbl1/Hn/XXCKzm5JPGKyZtRkSQyinzHRQCxyPTTIZnHN5jYfAuT105dY1ltxXlv52oqK4hML2AOCxb/N4/nrMZTBRdZXDTqIqhchNpDLneR35D1yy3wV/07uULTUV0AigAIKVba852g= 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=L6idNiH3; arc=none smtp.client-ip=209.85.210.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 Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6f8f34babd4so209107b3a.1 for ; Tue, 28 May 2024 15:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716936634; x=1717541434; 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=UTOH3e/EfW+pY1lF/i3FXaQ/pSIJmaxop4NhBeQiFYU=; b=L6idNiH37diLwjehmgo9dJ6wWrSW9rJ7seR9p+j2RMPPcVAX75e8svzoPFzRna/t51 KM1vC5iBhZ4RAhXLnsSBdGjfXet+EZG015rWVYzs5ASva4MBXrpDfExe12GHKbX4S2rP fLYaICQw2lb5QdqTMVtzZGzZuj6GSzmw623mGTQDRWiHj/cKEICImwwpeO5sqoI2XFJR ptTr/CsuTKWuIXgiqra0KGnGHTqaKJiVCtLJ0nIVhv4v2xo5qno0f8uMmSbcl5RmNW3b 1LkRaeEogfnX03hk4Y0yPC09gXOj9DTqf9jbp2tSyfyXfSs9sFIEkFRv3yOxKkPz2PDf a8ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716936634; x=1717541434; 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=UTOH3e/EfW+pY1lF/i3FXaQ/pSIJmaxop4NhBeQiFYU=; b=Up+kfhNPMyG1McSZfbCb7DVRCBJlAooA9HIWNHGd2TvMaxhI/J8BcDzehLFGLrHbG4 EtJv+dx1TDq4KQxXBWmXWW5Odr6LPGcSKZ5kg7ZZYRw0JuXPwgjOcBNmINzh20+PcnxF 2oeXxQCcAnOwD+IOcpe5xGTS+jpMQYRcVCwbTfn0bVQ4PIQNv4jLkwOE8gDOVC1zZDcO BewcIrxXYr91DU+YMrtxdHmsapGNvD3mv1lIUNl9PD92PGKbTvCDv4bEzEYZy8Tqm0Ax SyHw93ZrTh+Vdm1ct+F9n/KB6irkk4LBpIG6ZUgIcUnrssSYJhWYHtPeqvmUhSsdRZQS kjaQ== X-Forwarded-Encrypted: i=1; AJvYcCWpjtpBuR89mzXJRlqGHw0WG/bxUQSJhCj3vb3zerV3KRrOL7z2qR57+xfhxLHLZdHq3sNKcoupGhPJ4sHbtTnmp3q8+g1SNsOUuTGb X-Gm-Message-State: AOJu0YxIqnr98/pEXF/RvomofJXfBxj01ETC/zTa8UQGe62uEVLKnUpk oi99qAFAt661/V2umD1BddkK/kGuItJXcikfe86CdBKUPW+YE0Rne8Lj0BrRuxp/obFvbbFiVMm 6KQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:28cf:b0:6ea:df4b:86d0 with SMTP id d2e1a72fcca58-7020306b721mr1477b3a.2.1716936633742; Tue, 28 May 2024 15:50:33 -0700 (PDT) Date: Tue, 28 May 2024 15:50:32 -0700 In-Reply-To: <2d873eb4-67d2-446d-8208-a43a4a8aba14@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240522022827.1690416-1-seanjc@google.com> <20240522022827.1690416-5-seanjc@google.com> <2d873eb4-67d2-446d-8208-a43a4a8aba14@intel.com> Message-ID: Subject: Re: [PATCH v2 4/6] KVM: Add arch hooks for enabling/disabling virtualization From: Sean Christopherson To: Kai Huang Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Gao Content-Type: text/plain; charset="us-ascii" On Thu, May 23, 2024, Kai Huang wrote: > On 22/05/2024 2:28 pm, Sean Christopherson wrote: > > static int __kvm_enable_virtualization(void) > > { > > if (__this_cpu_read(hardware_enabled)) > > @@ -5604,6 +5614,8 @@ static int kvm_enable_virtualization(void) > > if (kvm_usage_count++) > > return 0; > > + kvm_arch_enable_virtualization(); > > + > > r = cpuhp_setup_state(CPUHP_AP_KVM_ONLINE, "kvm/cpu:online", > > kvm_online_cpu, kvm_offline_cpu); > > > Nit: is kvm_arch_pre_enable_virtualization() a better name? Hmm, yes? I don't have a strong preference either way. I did consider a more verbose name, but omitted the "pre" because the hook is called only on the 0=>1 transition of kvm_usage_count, and for some reason that made me think "pre" would be confusing. On the other hand, "pre" very clearly communicates that the hook is invoked, and _needs_ to be invoked (for x86), before KVM enables virtualization. So I'm leaning towards kvm_arch_pre_enable_virtualization(). Anyone else have an opinion?