Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2857878pxb; Tue, 24 Aug 2021 09:11:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpi9wEtDwN0Urn/qFOsPZtiX5cYJDg+97UFj872DVlT6YKm4+WCx1tWjvpwEUOjCQJNNcA X-Received: by 2002:a5d:9617:: with SMTP id w23mr31329821iol.115.1629821506633; Tue, 24 Aug 2021 09:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629821506; cv=none; d=google.com; s=arc-20160816; b=giup5BJbD5xTJT+3XnQiVjJ1VN3PktLtHoycGsjC577U+aPT3L4Ca9MGjbWAJJJAzu 96Gcb2b0nAscl32tSifZKy19ue8jEwA7jX1GAJIwratgDS7rN8iIoXpmbXHrXIIt8AWL vY+Q1qW9itQSvWoW8UGCFGKNHBzlsatKp5GfKddlb8MeXxgqbh4D3E6pCisMMlGP75PF AiQFJEsCeLiODjdvH7TFxrfYl+70g/Y4II4M17mX7yfnns1UWnsZ6e3XOpTda6y88o8V v04gZgeNWrdioR1oky8CJs4FzzKKb1ZbzzcUelT55OpEH55UC7UFBP2Zdnwm/AF5tt7K v4pA== 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=OfTc1qD5QEzHX66sy7oSqCLaN3XZ+0WymwWC2y0O8Ok=; b=SbAT7641vPLC/mQPzLPCZOxEOz5twUQtMT5j3K2CAt7zdKu034Zu5HJl6zVPgaUo3d KXIOiw3TGF6OAoZd0DBG3p2Guz/+K561mprJy5ZP4ujA0LLjDVeWVuwnoUkOdS9niurX DYC95mNrTu4TCKMviAQgeyO+SGYgUveXRagTJcK6d0Ua1Ipx4m2MMSQs8jFeiB4BfUJd XGNm6W5eNfe8Ogc5HauMH6mBI6z6Ln/k+6jSNtCL5o3P5AmPXVdqT8hbbebhJ8PkxiY5 pxYmVGhu0SKwOM+PCQiQ//LBZ4H2jjEjLymZQHLSO3JRrIX1nnEnBbL2FvYo0JSphNPQ +DIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=RhEK0K0K; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si19617571ilu.137.2021.08.24.09.11.33; Tue, 24 Aug 2021 09:11:46 -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=@alien8.de header.s=dkim header.b=RhEK0K0K; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232533AbhHXQK4 (ORCPT + 99 others); Tue, 24 Aug 2021 12:10:56 -0400 Received: from mail.skyhub.de ([5.9.137.197]:41244 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232300AbhHXQKz (ORCPT ); Tue, 24 Aug 2021 12:10:55 -0400 Received: from zn.tnic (p200300ec2f11440049ee8a07127e6a59.dip0.t-ipconnect.de [IPv6:2003:ec:2f11:4400:49ee:8a07:127e:6a59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 589881EC046C; Tue, 24 Aug 2021 18:10:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1629821405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=OfTc1qD5QEzHX66sy7oSqCLaN3XZ+0WymwWC2y0O8Ok=; b=RhEK0K0KsECKdd9IdOXaHrbQ1KITetii0T6wcrH4AIK1PK66jcUkguM566m6uc6W6QEg16 yAaDJBf3rWLzk8g5VLHgDsMThOxsA8+omCsmMwDtoDd+0Q2fVRcL4ZRK/0rSllPs7X7izE 6OJbfWkU1gsglQXVU03SXozXl1em+LE= Date: Tue, 24 Aug 2021 18:10:41 +0200 From: Borislav Petkov To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , 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=utf-8 Content-Disposition: inline In-Reply-To: <20210804181329.2899708-9-sathyanarayanan.kuppuswamy@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 04, 2021 at 11:13:25AM -0700, Kuppuswamy Sathyanarayanan wrote: > @@ -240,6 +243,32 @@ SYM_FUNC_START(__tdx_hypercall) > > movl $TDVMCALL_EXPOSE_REGS_MASK, %ecx > > + /* > + * For the idle loop STI needs to be called directly before > + * the TDCALL that enters idle (EXIT_REASON_HLT case). STI > + * enables interrupts only one instruction later. If there > + * are any instructions between the STI and the TDCALL for > + * HLT then an interrupt could happen in that time, but the > + * code would go back to sleep afterwards, which can cause > + * longer delays. <-- newline in the comment here for better readability. > There leads to significant difference in "There leads..." ? > + * network performance benchmarks. So add a special case for > + * EXIT_REASON_HLT to trigger sti before TDCALL. But this > + * change is not required for all HLT cases. So use R15 > + * register value to identify the case which needs sti. So, s/sti/STI/g > + * if R11 is EXIT_REASON_HLT and R15 is 1, then call sti > + * before TDCALL instruction. Note that R15 register is not > + * required by TDCALL ABI when triggering the hypercall for > + * EXIT_REASON_HLT case. So use it in software to select the > + * sti case. > + */ > + cmpl $EXIT_REASON_HLT, %r11d > + jne skip_sti > + cmpl $1, %r15d > + jne skip_sti > + /* Set R15 register to 0, it is unused in EXIT_REASON_HLT case */ > + xor %r15, %r15 > + sti > +skip_sti: > tdcall ... > +static __cpuidle void tdg_safe_halt(void) > +{ > + u64 ret; > + > + /* > + * Enable interrupts next to the TDVMCALL to avoid > + * performance degradation. That comment needs some more love to say exactly what the problem is. > + */ > + local_irq_enable(); > + > + /* IRQ is enabled, So set R12 as 0 */ > + ret = _tdx_hypercall(EXIT_REASON_HLT, 0, 0, 0, 1, NULL); > + > + /* It should never fail */ > + BUG_ON(ret); > +} -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette