Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp924410pxu; Fri, 23 Oct 2020 17:33:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCYBs1YbTM7L9RayrBGKnV70rEtat6mOfj3KENWokvksfthAkDYJxo+bMdJuS47JBvF3PZ X-Received: by 2002:aa7:d7d9:: with SMTP id e25mr4846929eds.253.1603499598324; Fri, 23 Oct 2020 17:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603499598; cv=none; d=google.com; s=arc-20160816; b=xTxVZk3nTvWbxTEjp5yZf33h6tLhF9PDFmjZmRqqIh6IzTMB07Lvnzp2mwe1vjV2oh obj+bKRhO/s0+5nw8Qn5zyCu+XTp/1GK/kmvMqz3JdkepF9nE1VWSC9LC5KqXjyuHlnW VOlr3YF6l+sBzVxcl70OSxYEBCh/UIKRq9gV61RYcpL+LUQXoPacbERg7HqEL0knhzLz bVGaFTrham5fBp86RLkUvROpzjYynySgJol2RJzFxIz20Bai3zK0oy2qDG5kz9IsfRvv 6SRq3TtfuY5/rYNA9GkhN16YTgzwrs6pOZYGPg2eUi+oYF4S8Ryb6d6pj6dmgBjZ0e+D 1M8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fXzCbMmS+pANPvGGOB4GzLFNuZZfqJXRrvXjWTUQXbM=; b=HWgSr5wHakUDrRNr1vg/FWvnfZhe49M7DKvPTJ5NJmzk3hjhHNszWlYuVfjet3EVt1 6NQt/lMU2vmpeDQ5BVQt7J10TWks7RnqVtc1o57EhInPKL4f0eoh/sFe7wWeUJp1G3K/ 4u6jU04BR17VPvfG1tlLyu0IoyNXMbSg2MujVKme2NuXV1uqkOGcXG9Jygvm0wMgQTRH wRpUAn3gHIQWVmz1bwF+QXOy9J1foVXEO/piTQ/6hNdTPYG2eSUl7thDBWagSQbGJaxO ywUPfH9K8+0oUQWUMLTtv/beuG064vv1dkS4wOVq8xdLN7lFwAEA1cAfRSCXGRBis4Q6 b0Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=g0+Cq3Y2; 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 h12si1932525edq.232.2020.10.23.17.32.56; Fri, 23 Oct 2020 17:33:18 -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=g0+Cq3Y2; 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 S1755348AbgJWVLk (ORCPT + 99 others); Fri, 23 Oct 2020 17:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752816AbgJWVLk (ORCPT ); Fri, 23 Oct 2020 17:11:40 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C9D8C0613CE for ; Fri, 23 Oct 2020 14:11:39 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id b1so3695927lfp.11 for ; Fri, 23 Oct 2020 14:11:39 -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=fXzCbMmS+pANPvGGOB4GzLFNuZZfqJXRrvXjWTUQXbM=; b=g0+Cq3Y2VhGGQSD9XXlMuRRYh8aZT17ZxEyY+io4SUKPWIrpX7Wagw+2y6I7NgfhjW QNWyw8TkCDrsyFCw3qZOHy6PHywxTR+nPRrWdFTBx8SX7CuhDluDK3I2uwzGorIa8Pt7 rCld7UmTscJPXgBdhu/Nkr2ZGRQI4pDmI62sA= 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=fXzCbMmS+pANPvGGOB4GzLFNuZZfqJXRrvXjWTUQXbM=; b=I5LtJTY3nGnX5qlkvxtX1cGPvk+5ZfFfg/rlfZ9UPrVcnOqouwKX9LhwLaTYKq1q6B rf3e4LjXj/5b2rYLc6ZWbBQcQsdrZIioPf1n7ORq4hnLEhwDPU1fjTFcdyfl+mirAzIw 7j4oGGIGR3KTrmzpQDjP+VhjhQjGu9mPhc0E1zBEKOEulNv2JXsDyjXd3oelqpF6rYSr hcvAFVRCctycW77RbFI/3sxMmWt+UyYvHxO/uVNB2ZLBsviNyVHtnhWzboXH7JyoAusO 5keunrjeWmKOYIS+EUq5gE0V9+bHvr8mV6WlM8/QtiEc5G65nS6ZNw1Y7roBPj/dXoqh FHDA== X-Gm-Message-State: AOAM532Elgv3Hgvfcd06cKcl7ibWNvwXkhlTFOf6B1e1Gb9Aozq2WhRH woTJj6z50cZMYzzQyxm+bRn7qyPxw0FRlg== X-Received: by 2002:a19:6e46:: with SMTP id q6mr1477021lfk.413.1603487497303; Fri, 23 Oct 2020 14:11:37 -0700 (PDT) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com. [209.85.208.179]) by smtp.gmail.com with ESMTPSA id i3sm242522lfe.23.2020.10.23.14.11.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Oct 2020 14:11:35 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id m20so3011614ljj.5 for ; Fri, 23 Oct 2020 14:11:35 -0700 (PDT) X-Received: by 2002:a2e:898c:: with SMTP id c12mr1737838lji.285.1603487495150; Fri, 23 Oct 2020 14:11:35 -0700 (PDT) MIME-Version: 1.0 References: <20201023203154.27335-1-linux@rasmusvillemoes.dk> <8820745F-E761-42E6-8A70-7B04EE70692C@zytor.com> In-Reply-To: <8820745F-E761-42E6-8A70-7B04EE70692C@zytor.com> From: Linus Torvalds Date: Fri, 23 Oct 2020 14:11:19 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/uaccess: fix code generation in put_user() To: Peter Anvin Cc: Rasmus Villemoes , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "the arch/x86 maintainers" , Sean Christopherson , Naresh Kamboju , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 23, 2020 at 2:00 PM wrote: > > There is no same reason to mess around with hacks when we are talking about dx:ax, though. Sure there is. "A" doesn't actually mean %edx:%eax like you seem to think. It actually means %eax OR %edx, and then if given a 64-bit value, it will use the combination (with %edx being the high bits). So using "A" unconditionally doesn't work - it gives random behavior for 32-bit (or smaller) types. Or you'd have to cast the value to always be 64-bit, and have the extra code generation. IOW, an unconditional "A" is wrong. And the alternative is to just duplicate things, and go back to the explicit size testing, but honestly, I really think that's much worse than relying on a documented feature of "register asm()" that gcc _documents_ is for this kind of inline asm use. So the "don't do pointless conditional duplication" is certainly a very sane reason for the code. Linus