Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp933804ybt; Wed, 1 Jul 2020 13:53:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLpGk6z62t1S6NOxork2Z90P7OZrc4tSKWd6jhNXjMu3AparsHgWD6KNoQiQJO3q4kyDt6 X-Received: by 2002:a17:906:d963:: with SMTP id rp3mr25657532ejb.54.1593636816509; Wed, 01 Jul 2020 13:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593636816; cv=none; d=google.com; s=arc-20160816; b=fpszpfu/0CLdBIAWYjlR4iPw1vpOafBhtL7c7TY/L1waUBZce2woVrfGalL0jG7HGG KHAQ1iqwWLlDdpv4NNAEHKDhq6TLXAyiqFdSAUYMZjczbwHU7J2QwWgTUnmQGv08R+Uh pHRmFVLxj0AbZ/t7aXPf1gOGzyUabBYIc+DfQTqSuc+UfiSn8ispcoZ6YlgecAJYsiDX FGYHizD9Enj34j/9rPYYGnILppdlsJ9inXlV1CUSuHIsth0vWoeT0csZsPeZkB9JRDZG 4o6DEHdvrtNxUxZRQ/Cgv6CfdikUX+RtjBwwvSjtOgexL66zpcA7vhlRNpK5LAgpXDqE GIBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LfKvJDfH+JgSbbJW8lIadNI33mwPlCXJ+3I1TVMp16U=; b=K59u5w5XeS0amUJeoCm2pTQFfUUaMltd+AgE4R+QHX/MUON9gmbRHiJEw2GgJrcA63 k0vPxP0PlD9R5pUABACwpu7Is+Jf4+0Hn5v3FfZ9uVPu2gfltgPkfg/2H6MRhINYyYEt UYR8XkmwsUlZwEgzHICr/X8t39fsCYk1DlKGY8KHeBRIKJ177FEeUQn2jIAUk2HEE6SV TXIjazHIQ/eSg5iM0C9cLcBB0CelOhnv8I6D3EpuzTf75exkS6etbqrarVxGHZXlSGij Nf2FfsopPZINLbzrwfBygoXKUCsgvdAnbtYqZzpJe/Yusv8TPjV0f+thih+6Swiu1OEN yScA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ajljEXMk; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si4053174ejn.679.2020.07.01.13.53.12; Wed, 01 Jul 2020 13:53:36 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ajljEXMk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbgGAUvb (ORCPT + 99 others); Wed, 1 Jul 2020 16:51:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbgGAUvb (ORCPT ); Wed, 1 Jul 2020 16:51:31 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 914E4C08C5C1 for ; Wed, 1 Jul 2020 13:51:30 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id n23so28921770ljh.7 for ; Wed, 01 Jul 2020 13:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LfKvJDfH+JgSbbJW8lIadNI33mwPlCXJ+3I1TVMp16U=; b=ajljEXMkWnVATS+Y0B8quCPCXM8vWY7jwlI22KMwwx56KKYKjJ5ho3GoksFEekSUav 9w08LuNbtn9E7JI9E3uHZi/Tpy2EzqacgSunOz8sILShQuJHUkPpBvgwdBQcTxOIK0aJ 3i3MAe//YEoHEdnGkOgZbG7KvOE3bgYfBntYw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LfKvJDfH+JgSbbJW8lIadNI33mwPlCXJ+3I1TVMp16U=; b=d9U05vZCW+cemHL2oEyfminJqPGl9UQ6SAwlsbRIrUAVqHHHmfKoZqUY9BA+Otr7aP wnU9GNpTp64l1R5RNPUpvhpDgOmCMNy8O9R5bVfLELSKSm6fnrd4F6OBPwihnDQCt6eb yDeLPNkSZ1Xs4XQrrC/3WmcSTa+XBtXDtqXBivPd2zCE8/s3JkDGZI2cjy80iRlzZM4b /begntmkcBXh8uanNe+REYh4p8uud60b2AJf+daAQUHaFQ4/eT8s5OfzuezAhGGMUxeE UI4VHwT6GrEUNZwjVcuYRSns5NFAORHpHfILOAK7VKBRgBzluXvbrd7nzygeZ1//9Wp8 D6KQ== X-Gm-Message-State: AOAM533NITCTMU7gpTnrEqhBP6YWnJlyt5n9wfcV2j7oZi6tZIOC2i/x HkC1zBpGg9MK+U5NIe95Q+Hvs5f5BG0= X-Received: by 2002:a2e:3909:: with SMTP id g9mr11947218lja.54.1593636688653; Wed, 01 Jul 2020 13:51:28 -0700 (PDT) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com. [209.85.208.178]) by smtp.gmail.com with ESMTPSA id 190sm2204693ljf.38.2020.07.01.13.51.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jul 2020 13:51:27 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id t25so24294318lji.12 for ; Wed, 01 Jul 2020 13:51:27 -0700 (PDT) X-Received: by 2002:a2e:9b42:: with SMTP id o2mr13959524ljj.102.1593636687265; Wed, 01 Jul 2020 13:51:27 -0700 (PDT) MIME-Version: 1.0 References: <5F1767D0-416A-4BA4-9DFF-E82D1EA3F5EE@amacapital.net> In-Reply-To: <5F1767D0-416A-4BA4-9DFF-E82D1EA3F5EE@amacapital.net> From: Linus Torvalds Date: Wed, 1 Jul 2020 13:51:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: objtool clac/stac handling change.. To: Andy Lutomirski Cc: Andy Lutomirski , Josh Poimboeuf , Peter Zijlstra , "the arch/x86 maintainers" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 1, 2020 at 1:36 PM Andy Lutomirski wrote: > > We ought to be able to do it the way I described and get decent code generation too. No, we really can't. Each access really needs to jump to an exception label. Otherwise any time you have multiple operations (think "strncpy()" and friends) you have to test in between each access. That is why *fundamnetally* the interface to "unsafe_get/put_user()" takes a label for the error case. There is absolutely no way to make any other interface work efficiently. (Unless, of course, you make the exception handling something that the compiler does entirely on its own. But that has never been a good idea for the kernel, and I wouldn't trust a compiler to do what the kernel needs). Side note: the labels can be hidden. I did (long ago) send out something that did a uaccess_try { val1 = unsafe_get_user(addr); val2 = unsafe_get_user(addr2); } uaccess_catch { error handling here }; kind of thing, but that was just syntactic wrapper around that label model. And honestly, it doesn't really change anything fundamental, it really ends up with exactly the same issues just with a slightly different syntax. (I did that because we had the nasty "put_user_ex()" interfaces, which were horrible horrible crap, and if one access took an exception, then all the other ones did too). The "label for error case" is actually simpler to follow both for the user and for a compiler. Yes, it's a bit odd, but once you get used to it, it's really quite regular. But having a different error handler for the "user_access_begin()" failure and the actual access failure really does end up generating duplicate code and confusion. Linus Linus