Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4006021pxb; Tue, 2 Nov 2021 02:21:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaceBohQL4P+mycoOnNR9a1dj/B0CuAMIx0rVJK98X2+ExS7w6LD+xg9h+12S7WejgqBNQ X-Received: by 2002:a5d:8c83:: with SMTP id g3mr24513530ion.24.1635844867861; Tue, 02 Nov 2021 02:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635844867; cv=none; d=google.com; s=arc-20160816; b=RVRHLyflSxIrTz2NxXvcGgLxMr3Ypj1ILnqB80dpFq/Z9WuHDZr/XyPTsEMBy0afKk 5GjNurE/fpgDIRRtuBIPrkXFSrt+IRM46tpKv5PPdaJ86bspihJ6f6H2RIQShkg0qLG8 Ty6edMLVlxVt+gV3ApGMMUbxG+8AIH0Wj/X87IeBgYLD+c3HJ6YwdMOM3Ps9ffMt60nU CgFCEXEOXAhgK5aYy/mJeUVYsjQMhDCg66CDzbzIajyUVGKwvFlfL35m3kx2QJMRjT3d 6yOWfYJ2MFCQA4AY7A9tciq6Y6G5+qATaa+nrAnvyOjTFrZ/PljNwSO0EPGiXeD7/lYJ H7UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=HtcF7JpPkJkehK75Asg/e1xDpcGAPCvDb+kH/wqQlZc=; b=JZPKtf04XSKegUXtrda5X2rBZ6PwJkZGBFH6rZKp830ArTITnroeo0F8aPpzfVviWA jb0EGgzoJJeiR4yWAvDDqFIFs5hqVDCjc/M5HC4UaMHGzXOOaTVN1iOsaKCGQvzsPcoS +2mOBJJ4Zd2g/PX1LrIFI9sfTosI6+hFGcE2dNtNTvtX7QBtJFQgae55mQlk764/a2mO ttWP+yAafgZG8m/xAeOzqB5GsXYumSRavXzKHJMFOz3YOUKsNb3lsladiHvpF5IE+kkk 5/ztOOW/xTzPtpH7z1mhUDjcP0tyLe4B2+nNwq24iW2Yk1ohEE0cOg5cZ5i3ddmVfZGc biZg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si11654808ill.182.2021.11.02.02.20.53; Tue, 02 Nov 2021 02:21:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbhKBJW0 (ORCPT + 99 others); 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)