Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1413982ybl; Wed, 18 Dec 2019 18:40:18 -0800 (PST) X-Google-Smtp-Source: APXvYqwBVEopvHxe2ugsFVKdGU6Ceb8sMyLqI1sdHSOjewOjzaiae4/pMop7S8oSHkDkHf69GijC X-Received: by 2002:a9d:708f:: with SMTP id l15mr6402048otj.286.1576723218654; Wed, 18 Dec 2019 18:40:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576723218; cv=none; d=google.com; s=arc-20160816; b=s0o4a+rD9WcGbaUexqnWC1xz33XibpeAPGtBySRDvnmNZBHa4+TVc0tWo64e9aL/7I dII/KT799L+GxUVkPyyVGw8PWUA68FLazzvfgpp3s1L7WxEGCAUIk/0ppXwX8N9JquuO HRw7WmrCzyYrEo4tyy9L7hEgw6mNA929ottYmva6sXAyPkUyl5F5dBr1u2wcqxb67flB 91qGNyk8ymNppNtcolyGS6ujWEtRollJ3zHUrWlKXfXD4TptRoZszdm7YMl4s7PIMQ1S zXHZbOOZ743NZB9aibLthVidDsf2aGxsBUL7HyzVx9HB9OUlBJXkxi8yovU9MfK3xeJE tjjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Ju+wzFmJxPb/MjXQXp5uXoPfAQTloNlfDQ2J3dMC5/g=; b=mEqFeYIBwGvGOUYWEU6AqlgdqmDkHbYkp9X0dUxu/Y460XVA6RbGfjvixCvG3lTHTF gGjRxMyDGhIfHvj48L3X4IOrkOybrGYZFLrZn0FWZJJzYl3fI4z4tDv2JuTDDZ9zvTZw A8LrRVl5c0DQsjfXWEMs9BkdfBLJnwwXhksJZat6HeSoc8uMLw3e4OLpBFGt72ybPRwS AIsSb+6fdIdwAXKK5sGB8DPmDAEC/gVRQdojqwclASH9Bk41mn+j0izJFwOM18lwjpiI ngSmz/1ZoxxStH/AuTu4rEu5Z7eOEoxhfQCWc0jjCwwae5ZXkC0RNgPahdt3oX65PkSp qnyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x6LKJnot; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si2422158oib.70.2019.12.18.18.40.06; Wed, 18 Dec 2019 18:40:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x6LKJnot; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbfLSCj0 (ORCPT + 99 others); Wed, 18 Dec 2019 21:39:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:41348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbfLSCjZ (ORCPT ); Wed, 18 Dec 2019 21:39:25 -0500 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1CDAF24650 for ; Thu, 19 Dec 2019 02:39:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576723164; bh=eajPtaQ53bdOFSFYbVWl33hqm6snpzaR1BIbqwcmipc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=x6LKJnotNQnkJ265YZC5x6L2ctNshQr3nxM4y9iPGrfKal2m6T+4DYPK5w1lrX7UF JOl1qDIPlKKaYnZ8/ZJOxRaoFPd634Wo4AfqC7KT64YGdyyWQFTcQglF3dm0reidyL uvoR417tgOLJftw8zWWhHUOdctLZIZiVCRPGNjkk= Received: by mail-wm1-f50.google.com with SMTP id q9so3883564wmj.5 for ; Wed, 18 Dec 2019 18:39:24 -0800 (PST) X-Gm-Message-State: APjAAAVo7z+EigjE7WtmP0lNJY3FQmXP0QlXuC4r9j9TAhHfMXzqSXMR ERQtUUQTYd7ZIXulHWGYgPSRxRXtGlvWiU5gwUjc/g== X-Received: by 2002:a1c:20d6:: with SMTP id g205mr7119194wmg.38.1576723162420; Wed, 18 Dec 2019 18:39:22 -0800 (PST) MIME-Version: 1.0 References: <08B92B44-CCA9-4B83-B9CC-F1601D44B73F@amacapital.net> <0053f606-f4f7-3951-f40b-b7bd08703590@suse.com> <62d9f87d-de55-3fb4-664d-d24897f4dd9b@suse.com> In-Reply-To: From: Andy Lutomirski Date: Wed, 18 Dec 2019 18:39:09 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86-64/entry: add instruction suffix to SYSRET To: Brian Gerst Cc: Jan Beulich , Andy Lutomirski , "the arch/x86 maintainers" , lkml Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 16, 2019 at 7:23 AM Brian Gerst wrote: > > On Mon, Dec 16, 2019 at 5:12 AM Jan Beulich wrote: > > > > On 13.12.2019 18:49, Andy Lutomirski wrote: > > > On Fri, Dec 13, 2019 at 1:55 AM Jan Beulich wrote= : > > >> > > >> On 12.12.2019 22:43, Andy Lutomirski wrote: > > >>> On Tue, Dec 10, 2019 at 7:40 AM Jan Beulich wro= te: > > >>>> > > >>>> On 10.12.2019 16:29, Andy Lutomirski wrote: > > >>>>>> On Dec 10, 2019, at 2:48 AM, Jan Beulich wro= te: > > >>>>>> > > >>>>>> =EF=BB=BFOmitting suffixes from instructions in AT&T mode is bad= practice when > > >>>>>> operand size cannot be determined by the assembler from register > > >>>>>> operands, and is likely going to be warned about by upstream gas= in the > > >>>>>> future. Add the missing suffix here. > > >>>>>> > > >>>>>> Signed-off-by: Jan Beulich > > >>>>>> > > >>>>>> --- a/arch/x86/entry/entry_64.S > > >>>>>> +++ b/arch/x86/entry/entry_64.S > > >>>>>> @@ -1728,7 +1728,7 @@ END(nmi) > > >>>>>> SYM_CODE_START(ignore_sysret) > > >>>>>> UNWIND_HINT_EMPTY > > >>>>>> mov $-ENOSYS, %eax > > >>>>>> - sysret > > >>>>>> + sysretl > > >>>>> > > >>>>> Isn=E2=80=99t the default sysretq? sysretl looks more correct, b= ut that suggests > > >>>>> that your changelog is wrong. > > >>>> > > >>>> No, this is different from ret, and more like iret and lret. > > >>>> > > >>>>> Is this code even reachable? > > >>>> > > >>>> Yes afaict, supported by the comment ahead of the symbol. syscall_= init() > > >>>> puts its address into MSR_CSTAR when !IA32_EMULATION. > > >>>> > > >>> > > >>> What I meant was: can a program actually get itself into 32-bit mod= e > > >>> to execute a 32-bit SYSCALL instruction? > > >> > > >> Why not? It can set up a 32-bit code segment descriptor, far-branch > > >> into it, and then execute SYSCALL. I can't see anything preventing > > >> this in the logic involved in descriptor adjustment system calls. In > > >> fact it looks to be at least partly the opposite - fill_ldt() > > >> disallows creation of 64-bit code segments (oddly enough > > >> fill_user_desc() then still copies the bit back, despite there > > >> apparently being no way for it to get set). > > > > > > Do we allow creation of 32-bit code segments on !IA32_EMULATION > > > kernels? > > > > As per above - I think so. > > > > > I think we shouldn't, but I'm not really sure. > > > > It may be a little exotic, but I can't see any reason to disallow > > a 64-bit process to switch to compatibility mode temporarily. One > > contrived use case could be to be able to invoke INTO or BOUND. > > I think it should be kept intact for future use by WINE. WINE is > currently set up so that 32/16-bit Windows emulation needs a 32-bit > build against 32-bit Linux libraries, using the kernel compat layer. > With many distributions wanting to drop 32-bit support this has been a > big sticking point. If WINE could be modified so that the core is > always built as 64-bit with 32-bit compatibility handled entirely in > userspace, that would remove its dependency on 32-bit Linux libraries > and thus wouldn't require IA32_EMULATION. I just read an article about WINE on Mac OS doing more or less this. I'm wondering if we should wire up set_thread_area() on x86_64 for uses like this. It even has a syscall number already -- it's just not wired up. Anyway, this isn't particularly high priority, IMO -- I don't think many people set IA32_EMULATION=3Dn. What we really ought to do is to get rid of the special ignore_sysret path and instead go through the normal syscall path but just do: if (!IS_ENABLED(IA32_EMULATION)) return -ENOSYS; or equivalent. The last thing we need is a whole special asm path that essentially no one uses.