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 46F544C98 for ; Thu, 19 Dec 2024 02:39:31 +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=1734575972; cv=none; b=gwCkuM/bH7H8oxca0FZIASEoYntycpfLIUvJ5Z19ipscifY9hIAkLrh1mCXcgaxsguJq6JQaD5JwJ+Mxgn0I/DzUH9odXkmWvWq+jIIARh9/V6d22OSdCRNkGvgzOKtYZI84NS+iEI8irG+Y9/hiTZg4HNS3KW5AjzL/05HLBQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734575972; c=relaxed/simple; bh=Xh0rRgh/7wTx9OjJbX6VMZNNlvLeBESz6cghvubzIN8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=czSFDj+gR1O4fSZLfzMvNaOuaxvp+oEO4lC9MpuWDRq1L2zAzivX+y22IeBRAv37cHO3J1RBDaMErXe0ivgMzMWB6fbqVvtLIB0xUufFYApGKpVXwIwWE33c/Q5DPs10gUxwLodHgycpb+iToUa5TD1xa6vmcpxPltb6cdYJES4= 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=gPfxqSt7; 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="gPfxqSt7" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-21638389f63so3090775ad.1 for ; Wed, 18 Dec 2024 18:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734575970; x=1735180770; 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=HHYSbe9XQeZJstEpYH57Z9R8AR6J6LY/n+7Uz7s2cjk=; b=gPfxqSt7gCm/K+DeOXqKCugyYmTfCcYFXa4KP6ot8aFka4a10+Fr3hpaqdF2Lkbrgp +zg7Vh5GqXHoMkt1eyrlh5Kr+9oxJLwMVIPxLgqj7qm1EbAXnkRDLfZpfu4qpM8VDgVX mWBLDREpqMUgrHM1c108e4IwHPSLsc4AlUPqV+7rsvsUQuX3HlhCHb4tJzU7nkZ4MeuE 5GGjk0d9nyiP+8QiX0w18waLU/ExU05bQt5/jCpP1vf+IXyVKGskPnqdnKYTcBfydXFa Vpi4aNly62aWPdyHJlpRuxs/xe2iCLC98AR/tozJe2zdBSFY3AAk6dGy0jS2vGCHb9/X BvLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734575970; x=1735180770; 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=HHYSbe9XQeZJstEpYH57Z9R8AR6J6LY/n+7Uz7s2cjk=; b=tnGJXAcqyHgj2QnTw5gSVIbsiXH3YwEX+TURGqv3MCyt4bLLOa4kWux7ZkIrE2qBKf WD/TjN4IFLQUET8v7PEMu9A5zS4iN/Vow3ECen+hMrQbws/NSk8rTDyAu7YkJs6uX+89 kxYIpH7Ept45hmRieLzCbrYL4LhkwZJ6RE6W5xxgD9Ch9lX+EqLasO4SM6JyieWg/Xd4 MWnB24Mg92uZKYpufy1vrYBu8nJi4GpWP1hyAeXxBQSXRQcCrIYaKNqt4ywk1wpnHu2f aHfB0W3TfnGci+4mrh88a+LQkwZd8kkjH5D4FA6L0Em3hqAQUUV15j0os6oRwSp0UIE2 OVtg== X-Forwarded-Encrypted: i=1; AJvYcCU2Go8lDdvqHXgj7cVDvdSW03B90oMoJ8mnDm8CJLJ1gWwqSbmLUwqSEpNWhY17fu3z3MtajKfnFCfdY9k=@vger.kernel.org X-Gm-Message-State: AOJu0YxrlYd1vTa51cZfVOilFBvo0jYdQN1cQN53eFwwZpGWOcCHagmJ Smw9XOyQ9jsU8jFsCG1OqUclv+BJvdIHL1lVQ/VYEJHbYK+nxhnAkocPp3BCJLrH0SXi3sqQRiu AcQ== X-Google-Smtp-Source: AGHT+IHj8XfMyZosspL2p28bl03iG3qIPDqUHcjBsXSpFYg/u147eJg72V6x67HacWjUgwfmDcZPxQb4Wd4= X-Received: from pjbsd6.prod.google.com ([2002:a17:90b:5146:b0:2ef:8055:93d9]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ecd1:b0:216:2804:a241 with SMTP id d9443c01a7336-218d7269e2bmr78557255ad.37.1734575970540; Wed, 18 Dec 2024 18:39:30 -0800 (PST) Date: Wed, 18 Dec 2024 18:39:29 -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: <20241121115139.26338-1-yan.y.zhao@intel.com> <20241121115703.26381-1-yan.y.zhao@intel.com> Message-ID: Subject: Re: [RFC PATCH 2/2] KVM: TDX: Kick off vCPUs when SEAMCALL is busy during TD page removal From: Sean Christopherson To: Yan Zhao Cc: pbonzini@redhat.com, kvm@vger.kernel.org, dave.hansen@linux.intel.com, rick.p.edgecombe@intel.com, kai.huang@intel.com, adrian.hunter@intel.com, reinette.chatre@intel.com, xiaoyao.li@intel.com, tony.lindgren@intel.com, binbin.wu@linux.intel.com, dmatlack@google.com, isaku.yamahata@intel.com, isaku.yamahata@gmail.com, nik.borisov@suse.com, linux-kernel@vger.kernel.org, x86@kernel.org Content-Type: text/plain; charset="us-ascii" On Thu, Dec 19, 2024, Yan Zhao wrote: > On Wed, Dec 18, 2024 at 08:10:48AM -0800, Sean Christopherson wrote: > > On Wed, Dec 18, 2024, Yan Zhao wrote: > > > > Anyways, I don't see any reason to make this an arch specific request. > > > After making it non-arch specific, probably we need an atomic counter for the > > > start/stop requests in the common helpers. So I just made it TDX-specific to > > > keep it simple in the RFC. > > > > Oh, right. I didn't consider the complications with multiple users. Hrm. > > > > Actually, this doesn't need to be a request. KVM_REQ_OUTSIDE_GUEST_MODE will > > forces vCPUs to exit, at which point tdx_vcpu_run() can return immediately with > > EXIT_FASTPATH_EXIT_HANDLED, which is all that kvm_vcpu_exit_request() does. E.g. > > have the zap side set wait_for_sept_zap before blasting the request to all vCPU, > Hmm, the wait_for_sept_zap also needs to be set and unset in all vCPUs except > the current one. Why can't it be a VM-wide flag? The current vCPU isn't going to do VP.ENTER, is it? If it is, I've definitely missed something :-) > > /* TDX exit handle takes care of this error case. */ > > if (unlikely(tdx->state != VCPU_TD_STATE_INITIALIZED)) { > > tdx->vp_enter_ret = TDX_SW_ERROR; > > @@ -921,6 +924,9 @@ fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu, bool force_immediate_exit) > > return EXIT_FASTPATH_NONE; > > } > > > > + if (unlikely(to_kvm_tdx(vcpu->kvm)->wait_for_sept_zap)) > > + return EXIT_FASTPATH_EXIT_HANDLED; > > + > > trace_kvm_entry(vcpu, force_immediate_exit); > > > > if (pi_test_on(&tdx->pi_desc)) { > Thanks for this suggestion. > But what's the advantage of this checking wait_for_sept_zap approach? > Is it to avoid introducing an arch specific request? Yes, and unless I've missed something, "releasing" vCPUs can be done by clearing a single variable.