Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2940225pxb; Tue, 24 Aug 2021 11:03:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU4YlUTHsfORPyz5e76h8BvYK6WjFX1kBRY5cPotNBZAB7C+57ZBCaQbGwjnoGuBOqV1Il X-Received: by 2002:a5d:8d0d:: with SMTP id p13mr32060030ioj.129.1629828219674; Tue, 24 Aug 2021 11:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629828219; cv=none; d=google.com; s=arc-20160816; b=UKLyBDYN7dDkPEVS1Br4icbKarxmjB0+uopCFr3aqZkvtrHpROotzpjKowvb7/5DKK gnQlgHm9DknuTdVxgv7tEfwmylw+QY5TZzkVqI6EM2W69bkMoFZJ/0ndJHA4KbQrzXAy aSZ+VFoos1rlpYAMKbguyfow/Rn3vun35PxmWHyXkFLnbxmezaPhtx7HQJ7XzX4yTyPd 3fnIDWSJq9pYSHVjoKTnT2Pq66EQVKBm6AKHp/wIoWrFmKCyjZlULVumNqAxXL04gEZU 0xYTZJvaJoB86y+0O3qI6a2rBHFkewiHgI9FaKB+tmT/YYu3jKEWW6QvaZtj00/II5PH NU0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1gDeRLms/d/PgRchCO82ssAS1m7T0+GYvbCOMiGz08E=; b=z7tw8Ml3RWEZuKVNCtoD4If/PmSj8h90gOlsW4GX+Y6MnmUm2Dnd3LHPGE9g4iasSw aI69Qyk0pWMe3gJtnMPIOyR7bvSaf83wshh06hSk4os0LsRq5F8+w1WlCplcV6uHd4Jc GdbzvVL1XbrdpHYMmmKRTnxD1LsTjdtGacFoIzu8IBXq7bmfBzE/qqBBwisg5tIDytnT IQsul4heh4bbwKh55OSDOLixCt1Q4quNbz0s0AnL6HrG2Z8mneRZszOTOVZigpNP/w0h tZQ7ZPurIuf44XItAIXUTYGBf83PZhJ50hjwG/4i1pLSUFMNf3aDn7uC13bpuSi5q23I tqwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OP8ji4Ga; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si17873728ilq.96.2021.08.24.11.03.25; Tue, 24 Aug 2021 11:03:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OP8ji4Ga; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239251AbhHXSCH (ORCPT + 99 others); Tue, 24 Aug 2021 14:02:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238946AbhHXSCA (ORCPT ); Tue, 24 Aug 2021 14:02:00 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3F71C061A31 for ; Tue, 24 Aug 2021 10:47:32 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id oc2-20020a17090b1c0200b00179e56772d6so2278624pjb.4 for ; Tue, 24 Aug 2021 10:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1gDeRLms/d/PgRchCO82ssAS1m7T0+GYvbCOMiGz08E=; b=OP8ji4GaiAhVi2KsHPmBGabJADwEbDP/kNIruomAqT35ZI0cljbBmQrdxzuJGDJJJZ YXIP1lHefzWnv6cwhN+ZMuk8M1mTA29ZAAsBrC/uAXMIjjUc+cseBSP6O4CwM0vZ//Db wAAq4L7gc14xEJ9zoeJ59sGLM43qBKigNPDca98s0BIuL0AgY0YY+mzn4Iu1+EEhdgmt 5GSGHUG4jmHUn19HDZguvXJLGnBuk/0P67iaEktVUX7BfACMLxL3o/aUtcCUv5KlXtdT iWxbRVYk49uRm9Bfp3IQeUk5VQ0T91iYR2a/NJQ6NsAki7b1SA6inm+KRNVMu1V4vTdw /5UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1gDeRLms/d/PgRchCO82ssAS1m7T0+GYvbCOMiGz08E=; b=b9ISB/FbMXrdn/1tZyxRm8p86GmKokDsHrUBCQ5CnA+Mp6hAV3B23AWW8JnZUiqR0S cD2oDi8ZunCXjxnOuoL0lsQ9RSulSGDuSnv1/OF+DvSJG97o5gD2mw6QvazNMfGkgEQP ERMWKnQRn/UYAXF6yfiZ3Hi2Y6pb5xp3xG4Xowjj/RCU3cSs0R5iWOLPLpEv/50A2R79 RUt5kzfkXG7Rxc4p+8aEWK/icxMl+edPWX/R/6WZhrs/gxLOr/OHd7bUizFrVB/g9UjY wmUeYO4Mbh3mn484TZwIY5xdz7pPkEraSYyzrNYWxeWdBDfxk2x7cEVixca+cXop+urs ssQQ== X-Gm-Message-State: AOAM532OW7hoj9Mfb/s/GEE5uwrsBARzt6EwsKvB+astuIYL0gxB6UQZ Bpy6XAKs0UT5RpMx0xw9mfRTQQ== X-Received: by 2002:a17:90b:1488:: with SMTP id js8mr4222306pjb.4.1629827252075; Tue, 24 Aug 2021 10:47:32 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id j68sm24096465pgc.44.2021.08.24.10.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 10:47:31 -0700 (PDT) Date: Tue, 24 Aug 2021 17:47:25 +0000 From: Sean Christopherson To: Borislav Petkov Cc: Kuppuswamy Sathyanarayanan , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 08/12] x86/tdx: Add HLT support for TDX guest Message-ID: References: <20210804181329.2899708-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210804181329.2899708-9-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 24, 2021, Borislav Petkov wrote: > On Tue, Aug 24, 2021 at 05:06:21PM +0000, Sean Christopherson wrote: > > It would be helpful to use local variables to document what's up, e.g. > > > > const bool irqs_enabled = true; > > const bool do_sti = true; > > > > ret = _tdx_hypercall(EXIT_REASON_HLT, irqs_enabled0, 0, 0, do_sti, NULL); > > Wait, is this do_sti thing supposed to be: > > * ... But this > * change is not required for all HLT cases. So use R15 > * register value to identify the case which needs sti. So, > * if R11 is EXIT_REASON_HLT and R15 is 1, then call sti > * before TDCALL instruction. > > ? > > > > > > + ret = _tdx_hypercall(EXIT_REASON_HLT, 0, 0, 0, 1, NULL); > ^^^ > Yeah, it must be it - the 1 there. > > And what's with the irqs_enabled first parameter? > > Is that used by the TDX module? It's passed to the (untrusted) VMM. The TDX Module has direct access to the guest's entire FLAGS via the VMCS. The VMM uses the "IRQs enabled" param to understand whether or not it should schedule the halted vCPU if an IRQ becomes pending. E.g. if IRQs are disabled the VMM can keep the vCPU in virtual HLT, even if an IRQ is pending, without hanging/breaking the guest.