From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDA7BC433EF for ; Tue, 2 Nov 2021 09:23:29 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E05560E8C for ; Tue, 2 Nov 2021 09:23:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5E05560E8C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.219824.380857 (Exim 4.92) (envelope-from ) id 1mhq0n-00079U-7A; Tue, 02 Nov 2021 09:23:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 219824.380857; Tue, 02 Nov 2021 09:23:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mhq0n-00079N-4D; Tue, 02 Nov 2021 09:23:21 +0000 Received: by outflank-mailman (input) for mailman id 219824; Tue, 02 Nov 2021 09:19:53 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mhpxQ-00059w-VP for xen-devel@lists.xenproject.org; Tue, 02 Nov 2021 09:19:52 +0000 Received: from out30-132.freemail.mail.aliyun.com (unknown [115.124.30.132]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0784807a-3bbe-11ec-8553-12813bfff9fa; Tue, 02 Nov 2021 09:19:51 +0000 (UTC) Received: from 30.22.113.90(mailfrom:laijs@linux.alibaba.com fp:SMTPD_---0UujaEY1_1635844786) by smtp.aliyun-inc.com(127.0.0.1); Tue, 02 Nov 2021 17:19:47 +0800 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0784807a-3bbe-11ec-8553-12813bfff9fa X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=laijs@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0UujaEY1_1635844786; Message-ID: Date: Tue, 2 Nov 2021 17:19:46 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH V4 04/50] x86/xen: Add xenpv_restore_regs_and_return_to_usermode() Content-Language: en-US To: Borislav Petkov , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Jan Beulich , Thomas Gleixner , Juergen Gross , Peter Anvin , xen-devel@lists.xenproject.org, Andy Lutomirski , Ingo Molnar , Dave Hansen , Boris Ostrovsky , Stefano Stabellini References: <20211026141420.17138-1-jiangshanlai@gmail.com> <20211026141420.17138-5-jiangshanlai@gmail.com> From: Lai Jiangshan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2021/11/2 16:58, Borislav Petkov wrote: >> */ >> >> - ALTERNATIVE "", "jmp swapgs_restore_regs_and_return_to_usermode", \ >> + ALTERNATIVE "", "jmp xenpv_restore_regs_and_return_to_usermode", \ > > Instead of sprinkling all those ALTERNATIVE calls everywhere, > why don't you simply jump to the xenpv-one at the > swapgs_restore_regs_and_return_to_usermode label itself and have a > single ALTERNATIVE there? > It will add a 5-byte NOP at the beginning of the native swapgs_restore_regs_and_return_to_usermode. I avoided adding unneeded code in the native code even if it is NOPs and avoided melting xenpv-one into the native one which will reduce the code readability. I will follow your preference since a 5-byte NOP is so negligible in the slow path with an iret instruction. Or other option that adds macros to wrap the ALTERNATIVE. RESTORE_REGS_AND_RETURN_TO_USERMODE and COND_RESTORE_REGS_AND_RETURN_TO_USERMODE (test %eax before jmp in native case)