Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 DFCD81BDA8C for ; Fri, 16 Aug 2024 20:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723839279; cv=none; b=jPqdOyHWhU2mKv0CTHc4lZeu/6R6CI9HjF+dGgCB7bhYUEcPm7fWbb373LMYe/8k+h+H9eSYeqLrZxgWbz4VaZBfHjCsPsQnZXy/Zulv6Op6IiGY6NlpBGmxBCN2ARS6L5Q+oziB661V/UyKFf7IeGPZiY8btpjad5Ab4UyLYHo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723839279; c=relaxed/simple; bh=GeAnRofml4TZ+kvvmlgfZ55lOxNPhJUBy4V8C/B/ZqI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gfhQeKd6TStwiF4l7NNfLXlDd7TdtYctbYroAKO5c6pomJxo9sNB0Gn2AT3JB47S4FxAMvUsYf/B3kj1bJ2yRdCmTqV15FEeAwGKyazhevcnJpSyVwNIYPb4GmMjv90tlyBQeQZknQzxpBWKFlYJLe2adR/maBGcMvAD7uw6vSo= 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=BdANXMol; arc=none smtp.client-ip=209.85.128.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="BdANXMol" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6addeef41a2so44040857b3.2 for ; Fri, 16 Aug 2024 13:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723839277; x=1724444077; 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=b+XtCDie/e/YZHW8+kNYaqurEPTj7Ow0w++u4stXh78=; b=BdANXMole8Ga1RZYe63zJhtHbK+0JWX/u0ioYHRnH3w2KOe3Ds4Bt5b/SJiMPp7MAI xB8ZDO55khvDWxG2u3zkvGe1A5hVECREXxy+aopefjogC87Jv1Fm36PWiPQzdFno/KM5 Z8717FKq0Y/O4jsVmhXmCKfsOvl5Xf151BEK9mbfVMCAc2aVvE43Yye2x+/SMSPgjgWI 0hg7fShTGgQqAWRP71BOdPemQRiFtWZq4BMw6G6FP6Ft9FLYqzoz009wzmijcyR0TRwg dwRRGp3K/htfItDXvEqYK9qQ8krZVPBiqdIA3WaK487fCiTJHeWbwNiXpPARcHg93Jk/ QU3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723839277; x=1724444077; 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=b+XtCDie/e/YZHW8+kNYaqurEPTj7Ow0w++u4stXh78=; b=LtbZ8g6wqp6wwj3D20sJQsie5RxaAerRCbztYqqppIy4hvJlOEaIr7zFoauI2jgjuy nOCTqfkOlpeq/BLGb2Jol1+RK7loFP5l8dv/0ViW+AdtsVB4z/N2cWbozsrRw9jCGFtm +zQ6DGekTC65322N/q1nw36nmQic/T9pxepzUEOGgroCE39eZNvMSMOODZOz0fCgPii1 3nKAFI3J/iRkha3GQqGwTctI1WXIYmsjIWp+2s/5JW0us0+llErZdfDwdJh9xTEJZrTf 1bW4by/PeUtDCbZQl2U0HOMFK0Sz/ibJFDhw6vpD42jqQ77Y2qoP+PhGlDUoAuox0wLx B6xA== X-Gm-Message-State: AOJu0Yw3LpTtEKhiwrigMHcGMTFgND/iXTyRRtJkIuFWXBmriu+9tYTT +hT69c0Dw7u+UnKjDNIdJGfSXLyLdlYfTbiRpneeJK3f4cYKg8uLvUhX+qCUpBAnMc3ig3c1J6h hTQ== X-Google-Smtp-Source: AGHT+IEn0xrjMnM4QulWbssX4RrAsftMvx75CGPCnBBwK21YPQG+1/RpR21AOZL1IqoJlRRK/J08+9MhePw= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2193:b0:e13:c454:166d with SMTP id 3f1490d57ef6-e13c45417d9mr15526276.11.1723839276827; Fri, 16 Aug 2024 13:14:36 -0700 (PDT) Date: Fri, 16 Aug 2024 13:14:35 -0700 In-Reply-To: <20240709175145.9986-4-manali.shukla@amd.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240709175145.9986-1-manali.shukla@amd.com> <20240709175145.9986-4-manali.shukla@amd.com> Message-ID: Subject: Re: [RFC PATCH v1 3/4] KVM: x86: nSVM: Implement support for nested Bus Lock Threshold From: Sean Christopherson To: Manali Shukla Cc: kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, pbonzini@redhat.com, shuah@kernel.org, nikunj@amd.com, thomas.lendacky@amd.com, vkuznets@redhat.com, bp@alien8.de, babu.moger@amd.com Content-Type: text/plain; charset="us-ascii" On Tue, Jul 09, 2024, Manali Shukla wrote: > @@ -758,6 +759,16 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm, > } > } > > + /* > + * If guest intercepts BUSLOCK, use guest's bus_lock_counter value, > + * otherwise use host bus_lock_counter value. > + */ > + if (guest_can_use(vcpu, X86_FEATURE_BUS_LOCK_THRESHOLD) && > + vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_BUSLOCK)) > + vmcb02->control.bus_lock_counter = svm->nested.ctl.bus_lock_counter; > + else > + vmcb02->control.bus_lock_counter = vmcb01->control.bus_lock_counter; Copying vmcb01's count to/from vmcb02 belongs in the core enabling patch. From KVM's perspective, the counter is associated with a vCPU, not a VMCB, and so the count should keep running across nested transitions. As written, taking only the core enabling patch will mean that L2 runs with the wrong count. Amusingly, because '0' means "always exit", L2 would run in a *more* restrictive environment due to the VMCB being zero-allocated.