From nobody Wed Jul 03 16:14:57 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 4WDlH55v8Pz5PfCY; Wed, 03 Jul 2024 16:14:57 +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 4WDlH54FVWz49qW; Wed, 3 Jul 2024 16:14:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720023297; 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=LZ72/iV7Em3FX948d/hO9kGQNbydRPnQTrRUsFFrS7w=; b=cm6JFml4WoNOHaROmV07Xtak8xy+0EPrRywmGbZfUFX5y9NP8b+7SbKQ3283WtAub3zQ6w GQdd3HVDJdPrdK6VdUmugUt0C98mS3tKoI4hv+6PSka8gFoJJH9Utum8YW3Hga1s41oxxD gwmmm4pS5xZmwbj60ST8+jOOeH7/8YP2L0Vo6eQhb08P+TVL3SZm5zoGQFlWmCVKyC1oiE wPsvBpFiaWPu9/i57VoCp3JF4pvRtWHXgmbrvuSSImnCp9mFVGsp7aqRL+PwwCVGIapUnl AiizSJiIMW3y7+oUestnAuOeeWqwWfw7c19StbExTlAwyoIG/49Xv9nRz6mkyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720023297; a=rsa-sha256; cv=none; b=rMXdQRjoXG2A+uv+Susy/ytWzOUF+rl399YhPr2BWzkFLte2ZNxD16mR78rX0Otdr/yfkN 4HOZFrfI8ZUxOITY5gZ9WoIorBWFhiEZdWCdsGjzPxMzqJERmM4Lat4lwoO7/mLTsT267U 8k5b2vTHvAg2ziZ03jqcdLNAwzxeEAYkEgcnMhkAa7FcTNTdWuEaH78gj2mfixg/XC/ysX TdyDi4l0t9E8Pk3Wojr3/2up+PGLZdV7obWG3nDoIvg1vpUOt0aqgpKL0ZCPoZ5B0Bur+s qiRMVv0bAeg6QJEq0nF7ijclnJHRaT50n67uoh3t/IXErxM2YVB1NMrlVCX+BQ== 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=1720023297; 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=LZ72/iV7Em3FX948d/hO9kGQNbydRPnQTrRUsFFrS7w=; b=Yhs2iGQ/LIc5SnF4IyfO0a6Fr5nXyzihoWbJDtu7gQ83uP/Njm3X7rMCKGiL1yYGQonMXP n1PwtWe0UnGMt7k835MdEQHjw4GjJ8YFds9Xm/ePNeucEcAJQZ8ccOTU+hJb6taDn36L+5 /VNOh+Zl0qNY+v6d1ClzjDe3lYchndKywkjZ/LzdDnOYhxoRvs/PJhrNFthO+MPtnXoWou 7U5rhT92jJPcycpWIo0fPBgoOzLmt/YDkufPQxYis87RYlhvfFJZjUNIUBXbC3eBLK0Vaq tb80thH7aICNFWGytyQKBXBt9WLzVpw2g++3qiQn365npkoLJAnmBdqSBb8WlA== 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 4WDlH53sG1zf13; Wed, 3 Jul 2024 16:14:57 +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 463GEvj9041572; Wed, 3 Jul 2024 16:14:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 463GEvIc041569; Wed, 3 Jul 2024 16:14:57 GMT (envelope-from git) Date: Wed, 3 Jul 2024 16:14:57 GMT Message-Id: <202407031614.463GEvIc041569@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: 2730f4291411 - main - amd64 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: 2730f4291411be0adc1c6ec421f72e146556579c Auto-Submitted: auto-generated The branch main has been updated by rlibby: URL: https://cgit.FreeBSD.org/src/commit/?id=2730f4291411be0adc1c6ec421f72e146556579c commit 2730f4291411be0adc1c6ec421f72e146556579c Author: Ryan Libby AuthorDate: 2024-07-03 15:36:31 +0000 Commit: Ryan Libby CommitDate: 2024-07-03 15:36:31 +0000 amd64 pcpu: fix clobbers, suppress warnings, and clean up These changes mostly apply to the !__SEG_GS section, which is no longer the normal compilation path. They're made to be consistent with changes to i386. - 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/D45827 --- sys/amd64/include/pcpu.h | 51 +++++++++++++++++++------------------------- sys/amd64/include/pcpu_aux.h | 4 ++-- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h index fb49eb31ef8a..213790d245dc 100644 --- a/sys/amd64/include/pcpu.h +++ b/sys/amd64/include/pcpu.h @@ -182,16 +182,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("movq %%gs:%1,%0; addq %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. @@ -200,14 +192,13 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __res; \ struct __s { \ u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ - } __s; \ + }; \ \ if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ sizeof(__res) == 4 || sizeof(__res) == 8) { \ - __asm __volatile("mov %%gs:%1,%0" \ - : "=r" (__s) \ - : "m" (*(struct __s *)(__pcpu_offset(name)))); \ - *(struct __s *)(void *)&__res = __s; \ + __asm __volatile("mov %%gs:%c1,%0" \ + : "=r" (*(struct __s *)(void *)&__res) \ + : "i" (__pcpu_offset(name))); \ } else { \ __res = *__PCPU_PTR(name); \ } \ @@ -222,15 +213,16 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4 || sizeof(__val) == 8) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("add %1,%%gs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("add %1,%%gs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "cc", "memory"); \ } else \ *__PCPU_PTR(name) += __val; \ } while (0) @@ -238,30 +230,31 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line"); /* * Sets the value of the per-cpu variable name to value val. */ -#define __PCPU_SET(name, val) { \ +#define __PCPU_SET(name, val) do { \ __pcpu_type(name) __val; \ struct __s { \ u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ - } __s; \ + }; \ \ __val = (val); \ if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ sizeof(__val) == 4 || sizeof(__val) == 8) { \ - __s = *(struct __s *)(void *)&__val; \ - __asm __volatile("mov %1,%%gs:%0" \ - : "=m" (*(struct __s *)(__pcpu_offset(name))) \ - : "r" (__s)); \ + __asm __volatile("mov %1,%%gs:%c0" \ + : \ + : "i" (__pcpu_offset(name)), \ + "r" (*(struct __s *)(void *)&__val) \ + : "memory"); \ } else { \ *__PCPU_PTR(name) = __val; \ } \ -} +} while (0) #define get_pcpu() __extension__ ({ \ struct pcpu *__pc; \ \ - __asm __volatile("movq %%gs:%1,%0" \ + __asm __volatile("movq %%gs:%c1,%0" \ : "=r" (__pc) \ - : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \ + : "i" (__pcpu_offset(pc_prvspace))); \ __pc; \ }) #endif /* !__SEG_GS */ diff --git a/sys/amd64/include/pcpu_aux.h b/sys/amd64/include/pcpu_aux.h index 9d776274a57d..6e27162e1fb4 100644 --- a/sys/amd64/include/pcpu_aux.h +++ b/sys/amd64/include/pcpu_aux.h @@ -54,8 +54,8 @@ __curthread(void) { struct thread *td; - __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu, - pc_curthread))); + __asm("movq %%gs:%c1,%0" : "=r" (td) + : "i" (offsetof(struct pcpu, pc_curthread))); return (td); } #define curthread (__curthread())