From nobody Wed Jul 03 16:14:56 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WDlH446vFz5Pf3R; Wed, 03 Jul 2024 16:14:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WDlH43b6zz49qT; Wed, 3 Jul 2024 16:14:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720023296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5wbwUOMAYQ9EK7r/yTb+rjSZxDRO2A2iWFp5URZWT50=; b=BEMqGP3bXMGfUAUehZI35RVjFdqIM2iLWSNOnk08gG5MD7XcalmMGV5DNSP9YGZmRKMJ7d 9FBbOPZ/LsVGpHpnLBg4HSAItwf68s9N6j66OhXOUV3UleMpObFACrUBsC7Jl6vwdOxs8+ yf4wAA7yOhQe7hTwi6v96RZ06hyQmuAhrETeUOxbCrw/alrbOhyJcLYq2TlQfTBo+zS3e1 GWqNupA/AQV7BeQLuhuEY//2/Y9UXzdD6y5AJlQ5USqgBxGWjsvRFkExboElAZI2kAl/Ly lxs5oNpIF2qL5QIpMqFycaL7XUn361KEuZ7MivfOT9s0saimvtHi7fIst7K0Ew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720023296; a=rsa-sha256; cv=none; b=hLb4TiBjEL4jfeG1/YAYxwcMncrAqbZtiD2cPPgZ+7YOtjJjeKAwzY9M6s8K+5qEOumj56 i5jAjFX+WfL+8HugpNUNDmGcz9fpPrupwyLL9QtNRRfdtUzc8OTUU16QIfvGg0egULFiYN PhfBxUkF0MHdTjUdfq0PKSHlygzfY5wdytS0Xj9XPm3zLDO5FljH6GwatHRqD2u3UzcDid 2PT7HgOWYRVAS/O1hZcj0JA4KJ2t9wZ3Cfb0ExL8ZsQufkd7iup9l/LLExHExbW8CCTGP7 HOA2j8uJk8517/duPCNWDMTWlIpqN4LtmNt4FUa5A8IiATUlVMqhDe79si1Y+Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720023296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5wbwUOMAYQ9EK7r/yTb+rjSZxDRO2A2iWFp5URZWT50=; b=gEL6LK/6U6Xd72UHAvDLWl/0Fjnqrj4VieGsT1T7VkPiv749QOkjBo8Od8qOw2mKmYQ5lY 6I0Dd1YKJ2g+U9GQHKRYETDqeDsazMyySgjDZoOsgN8MixUEeo5rJPCXFSBUAtBcEnPuN3 SE3AoC9C25NItA16e5mglYCR8tecHIa+UlAgeAtDaz3Div+jMA42ruklSYsD7a/BeQBWv8 T3MeStihEn043fIsS8K+WdUsNRCrYbfS4BkLvXICF8M0zYM0kgHxUmbY5zKOAAa1Qq7U5H o3gd+C5KadC/X12TLBz2qUUr41X9QoSudTc+jaG8HJSNlaQG5R2BGE67sKU1PA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WDlH42tJ2zdgC; Wed, 3 Jul 2024 16:14:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 463GEum5041517; Wed, 3 Jul 2024 16:14:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 463GEu1w041514; Wed, 3 Jul 2024 16:14:56 GMT (envelope-from git) Date: Wed, 3 Jul 2024 16:14:56 GMT Message-Id: <202407031614.463GEu1w041514@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ryan Libby Subject: git: ab92c99aa56f - main - i386 pcpu: fix clobbers, suppress warnings, and clean up List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rlibby X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ab92c99aa56fdec4a06f9af5f30f87ef08fbeb0e Auto-Submitted: auto-generated The branch main has been updated by rlibby: URL: https://cgit.FreeBSD.org/src/commit/?id=ab92c99aa56fdec4a06f9af5f30f87ef08fbeb0e commit ab92c99aa56fdec4a06f9af5f30f87ef08fbeb0e Author: Ryan Libby AuthorDate: 2024-07-03 15:35:31 +0000 Commit: Ryan Libby CommitDate: 2024-07-03 15:35:31 +0000 i386 pcpu: fix clobbers, suppress warnings, and clean up - Add missing cc clobber to __PCPU_ADD (which is currently unused). - Allow the compiler the opportunity to marginally improve code generation from __PCPU_PTR by letting it figure out how to do the add (also removing the addition fixes a missing cc clobber). - Quiet gcc -Warray-bounds by using constant operands instead of bogus memory references. - Remove the struct __s __s temporaries, just cast through the type. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D45826 --- sys/i386/include/pcpu.h | 47 +++++++++++++++++++-------------------------- sys/i386/include/pcpu_aux.h | 8 ++++---- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index ef3f5cc9dff7..d51763b20798 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -108,16 +108,8 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); /* * Evaluates to the address of the per-cpu variable name. */ -#define __PCPU_PTR(name) __extension__ ({ \ - __pcpu_type(name) *__p; \ - \ - __asm __volatile("movl %%fs:%1,%0; addl %2,%0" \ - : "=r" (__p) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \ - "i" (__pcpu_offset(name))); \ - \ - __p; \ -}) +#define __PCPU_PTR(name) \ + (&get_pcpu()->name) /* * Evaluates to the value of the per-cpu variable name. @@ -126,14 +118,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __res; \ struct __s { \ u_char __b[MIN(sizeof(__res), 4)]; \ - } __s; \ + }; \ \ if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ sizeof(__res) == 4) { \ - __asm __volatile("mov %%fs:%1,%0" \ - : "=r" (__s) \ - : "m" (*(struct __s *)(__pcpu_offset(name)))); \ - *(struct __s *)(void *)&__res = __s; \ + __asm __volatile("mov %%fs:%c1,%0" \ + : "=r" (*(struct __s *)(void *)&__res) \ + : "i" (__pcpu_offset(name))); \ } else { \ __res = *__PCPU_PTR(name); \ } \ @@ -148,15 +139,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__val), 4)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("add %1,%%fs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("add %1,%%fs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "cc", "memory"); \ } else \ *__PCPU_PTR(name) += __val; \ } while (0) @@ -168,15 +160,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__val), 4)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("mov %1,%%fs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("mov %1,%%fs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "memory"); \ } else { \ *__PCPU_PTR(name) = __val; \ } \ @@ -185,9 +178,9 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); #define get_pcpu() __extension__ ({ \ struct pcpu *__pc; \ \ - __asm __volatile("movl %%fs:%1,%0" \ + __asm __volatile("movl %%fs:%c1,%0" \ : "=r" (__pc) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \ + : "i" (__pcpu_offset(pc_prvspace))); \ __pc; \ }) diff --git a/sys/i386/include/pcpu_aux.h b/sys/i386/include/pcpu_aux.h index 9d15ee1f3ee3..a38faf9af964 100644 --- a/sys/i386/include/pcpu_aux.h +++ b/sys/i386/include/pcpu_aux.h @@ -49,8 +49,8 @@ __curthread(void) { struct thread *td; - __asm("movl %%fs:%1,%0" : "=r" (td) - : "m" (*(char *)offsetof(struct pcpu, pc_curthread))); + __asm("movl %%fs:%c1,%0" : "=r" (td) + : "i" (offsetof(struct pcpu, pc_curthread))); return (td); } #define curthread (__curthread()) @@ -60,8 +60,8 @@ __curpcb(void) { struct pcb *pcb; - __asm("movl %%fs:%1,%0" : "=r" (pcb) - : "m" (*(char *)offsetof(struct pcpu, pc_curpcb))); + __asm("movl %%fs:%c1,%0" : "=r" (pcb) + : "i" (offsetof(struct pcpu, pc_curpcb))); return (pcb); } #define curpcb (__curpcb())