Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp686394rwd; Thu, 8 Jun 2023 06:31:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4mg1YrgWZ9Gm/iBfdQxyWXDfTcylBMDkethi1D9OnaYsjZtXU+3csJReKACXZMsTUORSM0 X-Received: by 2002:a05:6a20:244f:b0:117:6b17:106f with SMTP id t15-20020a056a20244f00b001176b17106fmr3913186pzc.11.1686231102750; Thu, 08 Jun 2023 06:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686231102; cv=none; d=google.com; s=arc-20160816; b=Z8KClax0o00m+LVYJaZb8206yfSAgUqXdWkX20nlVrklWgV0zU1NXTPF7MzeVUqBbc bEw3dSZPowz35I/G1hB3DhaAhYHPgnVm6LlH6oIKwzaZLjstpEFYIFego6quZfIrtmm9 yF0oDlJm/5ydM2BvDBOXiUTIB7NHaVn8oWlGZgkSQplClGMEAWpnNI1MG55uFbDtVYzq AdmlvDtsLj+Mn3sgbhA89trQWidlkYeM5DU1o7fSkGYb/epjHyMirH8XXze4msrGjSqf hPZ7VxyZW4PkaCTb/NzRW1P1BUQCUAYTM9TlSzA8HkDTUKn//CqKAsr4HDuCzgO2f+NG W8rg== 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=PWoXpUmlC45fg1IpqI9CEjVwcpGlHdFT1Fkl0ZaYbyQ=; b=ci03DFlS9Tm4QfzoZz/TQFdbqbzmej47JUS73yIw2vSIuntQ03DqjjvDDpwTJn7hNY R0/kgw+htGdklV9c8FXxE/jM7aFMmetmH0Xwg6IZ/SN0RRDdsGP4EGCVQdT5EG7xdPoZ aigH9eBiEEnPIJ8BL7yB3bjTWd6MpY3VplEUkevrIWIb1H5AZxG1SnK28XxU8w1KXI5E nQqb7o3rEWNK9WZr/2W18YRoH3I4yKhEmRHSHUbZaKmwV2fwJiEGZd51reXU4cdRI8RB cJeqsW2psYAuirLJ7ulRyTJKbTVD1NUoaonve/Ol311vA/Qlytd4MFDCGDLSS3Ehlfyw BwSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nIW8kQyI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s29-20020a63925d000000b0053b88e08e85si986153pgn.242.2023.06.08.06.31.30; Thu, 08 Jun 2023 06:31:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nIW8kQyI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233162AbjFHNWd (ORCPT + 99 others); Thu, 8 Jun 2023 09:22:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234979AbjFHNWa (ORCPT ); Thu, 8 Jun 2023 09:22:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E875530D3; Thu, 8 Jun 2023 06:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=PWoXpUmlC45fg1IpqI9CEjVwcpGlHdFT1Fkl0ZaYbyQ=; b=nIW8kQyI7IAqekwsHeAYisHbpb 3GisiixqCf6RDzaBUTVnWt+aNvye5Dz6QhDT1RQJvCwAMhydTBsU0ieikGZNP8qN+Xg9ZlXrlHO5p NbFsIpeMwY6d08ji/nheXkQNlMoejJxRUbSTyG5wqTrdQP/ljqS5fpUziq5N533bfQwqlT4up1T88 KVlXCPgrqyGHW1Ff6xqLkEIcP+cCJ+yO4lY2mioNfItPmH49bNBA5Cq5Cxv+PdMApJ1d+L5fECu9E yXrKenzdPGaCeCcIb626ssp7AGZvpb+WNdL7K/oDe8Ni86nhD2twXXo/SdG8DJ6lch4b91w8snLwL bWvCiQZw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1q7FZx-00FUw2-GQ; Thu, 08 Jun 2023 13:21:29 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 623A4300274; Thu, 8 Jun 2023 15:21:27 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4864D23FF6AD1; Thu, 8 Jun 2023 15:21:27 +0200 (CEST) Date: Thu, 8 Jun 2023 15:21:27 +0200 From: Peter Zijlstra To: Tianyu Lan Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, daniel.lezcano@linaro.org, arnd@arndb.de, michael.h.kelley@microsoft.com, Tianyu Lan , linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, vkuznets@redhat.com Subject: Re: [PATCH 5/9] x86/hyperv: Use vmmcall to implement Hyper-V hypercall in sev-snp enlightened guest Message-ID: <20230608132127.GK998233@hirez.programming.kicks-ass.net> References: <20230601151624.1757616-1-ltykernel@gmail.com> <20230601151624.1757616-6-ltykernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230601151624.1757616-6-ltykernel@gmail.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 01, 2023 at 11:16:18AM -0400, Tianyu Lan wrote: > From: Tianyu Lan > > In sev-snp enlightened guest, Hyper-V hypercall needs > to use vmmcall to trigger vmexit and notify hypervisor > to handle hypercall request. > > There is no x86 SEV SNP feature flag support so far and > hardware provides MSR_AMD64_SEV register to check SEV-SNP > capability with MSR_AMD64_SEV_ENABLED bit. ALTERNATIVE can't > work without SEV-SNP x86 feature flag. May add later when > the associated flag is introduced. > > Signed-off-by: Tianyu Lan > --- > arch/x86/include/asm/mshyperv.h | 44 ++++++++++++++++++++++++--------- > 1 file changed, 33 insertions(+), 11 deletions(-) > > diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h > index 31c476f4e656..d859d7c5f5e8 100644 > --- a/arch/x86/include/asm/mshyperv.h > +++ b/arch/x86/include/asm/mshyperv.h > @@ -61,16 +61,25 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output) > u64 hv_status; > > #ifdef CONFIG_X86_64 > - if (!hv_hypercall_pg) > - return U64_MAX; > + if (hv_isolation_type_en_snp()) { > + __asm__ __volatile__("mov %4, %%r8\n" > + "vmmcall" > + : "=a" (hv_status), ASM_CALL_CONSTRAINT, > + "+c" (control), "+d" (input_address) > + : "r" (output_address) > + : "cc", "memory", "r8", "r9", "r10", "r11"); > + } else { > + if (!hv_hypercall_pg) > + return U64_MAX; > > - __asm__ __volatile__("mov %4, %%r8\n" > - CALL_NOSPEC > - : "=a" (hv_status), ASM_CALL_CONSTRAINT, > - "+c" (control), "+d" (input_address) > - : "r" (output_address), > - THUNK_TARGET(hv_hypercall_pg) > - : "cc", "memory", "r8", "r9", "r10", "r11"); > + __asm__ __volatile__("mov %4, %%r8\n" > + CALL_NOSPEC > + : "=a" (hv_status), ASM_CALL_CONSTRAINT, > + "+c" (control), "+d" (input_address) > + : "r" (output_address), > + THUNK_TARGET(hv_hypercall_pg) > + : "cc", "memory", "r8", "r9", "r10", "r11"); > + } > #else Remains unanswered: https://lkml.kernel.org/r/20230516102912.GG2587705%40hirez.programming.kicks-ass.net Would this not generate better code with an alternative?