From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F10733E4C9B for ; Wed, 18 Mar 2026 15:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773846202; cv=none; b=OdF98ADk84Y/HJyx2eVoJNHmnWtTv1/MRiiD5BS7mrYGi0D5m3TKGkHbTgvwyyoXZ5FJoOjuXHAFA9qhs6DSu0/ChmxmeuA13apA4xwsl4I86MW37puV9fKqOrX3StBFBhxo4kcB0j+6jSL+EPgb5bs9TJyFWOAQpgmZpGlrGmM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773846202; c=relaxed/simple; bh=TVmjXlAAQfXwPDqvhC13S/lj3j26hSuaaLJBn3TgLuA=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z4xM7To8896qNWBcg/KG+otm6PxgzB2QOvjDrPPw6FcyO/uY5MSOQ4C9itrTIIm0l8DFc9MqHebwGKoa54DBpd/S0vmqNjeHcj0c7G/AD89fEw/B8TTE2EcRqUCkgO87nhImyrh7nbDV1t7/r4ysm3YEq0KaU0lFxnuzXyTqimY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WBpYiNmu; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WBpYiNmu" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-b976536806cso136858866b.0 for ; Wed, 18 Mar 2026 08:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773846198; x=1774450998; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=oLemaLu9z2ZMYfje75elcM3d5qjeXzlCv7VRa44vB9I=; b=WBpYiNmuamGuXI71CRU67NcmrtLy5A54PgursZcx27Q0V9sPsARFMJxMDkajvzncIt Wque2vtKq7iyF38dtUxWSSkAUlUOS7gXp4LLUlDS/LwrXzbT5GrDHMmbdpSyCUWgGQvg L7vJ7ptr+/+6n8h8dga/MdMOVA2+zfYQDMe64i4FB9M2ILku2HKNOxH7NIRdfznFMH5I YOTbissp2YaXYuICORgYVSKV7DHWuywjCCejNOlDEVZ7JB+V7Fgc7UuobchlLpkjRIbl 4YVFSWcHbj9q++fSvv02UlOJOp5FOm244A2Y81Mds6ye1Wrnyt/qCNxr4nuOIUN52X8E JiNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773846198; x=1774450998; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=oLemaLu9z2ZMYfje75elcM3d5qjeXzlCv7VRa44vB9I=; b=jDElSJKHDvqDon5BIld+vjnBvRicdNFSWZuztf83cJhWF4D9gbnDwkOm+cWRwflbJ7 uPErICq8n0KzwbFK4USXqrCLR281fpg9w7qp8w5pEVvdMoefHJfriorrPwg/5D/UtHC3 32qYY6gfDz8ARtHwsvjS5y1td7c43BXT62pCEjf+rjmyKCVE+8IgF27JVh1+CmE3Wl3D Ty6EZY6BE1zBX4kWRvJvnPc+/7VcGnH0Q8H2g0UPq9EVfOjl6QhSGqawwBsJi2d/AF4u pRfQvIsZ7fmYCiLjX8M6XWyj4evxYBxy6U4I1z/nPiLCZmT3xhy8Px6BBOPF5gwbRnTx 7dQw== X-Forwarded-Encrypted: i=1; AJvYcCUo6zVw6D8P4tgjEzqvOXGqOk8HiE8XiqhCg58jhJ+eNS0NWcC3RU7Voqh3H0nIFLJrNCbxipScRPlsnpc=@vger.kernel.org X-Gm-Message-State: AOJu0YzIuaal8hCubIQArkSMWZed5LccpNL44pAcb0kzEgIavQra54M+ 4Zqbbil69k0OEZT85TvJN20yZBKxE0jMumb6VU6K75WeH71yZkpyVSf8 X-Gm-Gg: ATEYQzykV4MaO2nBOxumSYrWt0O0/ua0ryAQXPF+o1oPapg81IM/8gIWFswpK5pCtyJ zy+IeUEt8lRiVW2ofAVm04eJ7DopE5si43LAYZ2D106tzkASvHNKg4RjqbojpgrG0RRduO1CxtT 2gXddiWYY80FcR89vYQ3cOenu9QsZpGR8PwFWhP/0qw4hdq6+pqxgPVLRgp+11MLo/1/1WBJFS1 WheiuKO/eaSTU79291pFs2Tes397KD0bpHRq82YHhqu277xufYKw/fCdac6xCSTQlCZQjCWkbt/ yuuetEZty3po2Q3T+eUbV/QD3F4bGu+ER94BYW/MCd6cSUOT4vrFvvBCS59ZO1o81I8C/J4Znvi 18FoDkRLpz4pYAolU8eNCwc5TMn5Of7qTpdLbjROjUxl4+yOLqpCxN2+JTn7Grit6DCHKvbHSyP yBtgr659vAwqUmH+h9RBB1TVcxZr4eBjE5yhCZbpaCYewK37RSZN02RR41Rko2TZ3v X-Received: by 2002:a17:907:1b23:b0:b97:9099:7b3 with SMTP id a640c23a62f3a-b97f4aefe3dmr232458766b.44.1773846197528; Wed, 18 Mar 2026 08:03:17 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b518a2cd3sm6958289f8f.32.2026.03.18.08.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 08:03:16 -0700 (PDT) Date: Wed, 18 Mar 2026 15:03:15 +0000 From: David Laight To: Uros Bizjak Cc: x86@kernel.org, linux-kernel@vger.kernel.org, "Peter Zijlstra (Intel)" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: Re: [PATCH] x86/asm: Switch clflush alternatives to use %a address operand modifier Message-ID: <20260318150315.6cff1844@pumpkin> In-Reply-To: <20260318090831.501191-1-ubizjak@gmail.com> References: <20260318090831.501191-1-ubizjak@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 18 Mar 2026 10:08:11 +0100 Uros Bizjak wrote: > The inline asm used with alternative_input() specifies the address > operand for clflush with the "a" input operand constraint and > explicit "(%[addr])" dereference: > > "clflush (%[addr])", [addr] "a" (addr) > > This forces the pointer into %rax and manually encodes the memory > operand in the template. Instead, use the %a address operand > modifier and relax the constraint from "a" to "r": > > "clflush %a[addr]", [addr] "r" (addr) > > This lets the compiler choose the register while generating the > correct addressing mode. Aren't these two independent changes? %a saves you having to know how to write the memory reference for the architecture - so is the same as (%[addr]) (assuming att syntax). I think the assembler handles the one 'odd' case of (%rbp). Was there ever a reason for using "a" rather than "r" - it seems an unusual choice. I also think there should be a "memory" clobber - but it probably makes no difference for these two cases. David > > No functional change intended. > > Signed-off-by: Uros Bizjak > Acked-by: "Peter Zijlstra (Intel)" > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: Dave Hansen > Cc: "H. Peter Anvin" > --- > arch/x86/include/asm/mwait.h | 3 ++- > arch/x86/kernel/process.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h > index e4815e15dc9a..fcb7299b293a 100644 > --- a/arch/x86/include/asm/mwait.h > +++ b/arch/x86/include/asm/mwait.h > @@ -116,7 +116,8 @@ static __always_inline void mwait_idle_with_hints(u32 eax, u32 ecx) > if (static_cpu_has_bug(X86_BUG_MONITOR) || !current_set_polling_and_test()) { > const void *addr = ¤t_thread_info()->flags; > > - alternative_input("", "clflush (%[addr])", X86_BUG_CLFLUSH_MONITOR, [addr] "a" (addr)); > + alternative_input("", "clflush %a[addr]", > + X86_BUG_CLFLUSH_MONITOR, [addr] "r" (addr)); > __monitor(addr, 0, 0); > > if (need_resched()) > diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c > index 4c718f8adc59..8e295fb19b10 100644 > --- a/arch/x86/kernel/process.c > +++ b/arch/x86/kernel/process.c > @@ -921,7 +921,8 @@ static __cpuidle void mwait_idle(void) > if (!current_set_polling_and_test()) { > const void *addr = ¤t_thread_info()->flags; > > - alternative_input("", "clflush (%[addr])", X86_BUG_CLFLUSH_MONITOR, [addr] "a" (addr)); > + alternative_input("", "clflush %a[addr]", > + X86_BUG_CLFLUSH_MONITOR, [addr] "r" (addr)); > __monitor(addr, 0, 0); > if (need_resched()) > goto out;