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 31BA7C433EF for ; Tue, 2 Nov 2021 09:19:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E0BA60EE5 for ; Tue, 2 Nov 2021 09:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbhKBJW0 (ORCPT ); Tue, 2 Nov 2021 05:22:26 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:36603 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhKBJWZ (ORCPT ); Tue, 2 Nov 2021 05:22:25 -0400 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; 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 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)