From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Date: Mon, 30 Sep 2024 15:48:25 -0700 Subject: [PATCH v2 03/13] KVM: selftests: Fudge around an apparent gcc bug in arm64's PMU test In-Reply-To: References: <20240911204158.2034295-1-seanjc@google.com> <20240911204158.2034295-4-seanjc@google.com> Message-ID: List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Mon, Sep 30, 2024, Sean Christopherson wrote: > On Wed, Sep 11, 2024, Sean Christopherson wrote: > > Use u64_replace_bits() instead of u64p_replace_bits() to set PMCR.N in > > arm64's vPMU counter access test to fudge around what appears to be a gcc > > bug. With the recent change to have vcpu_get_reg() return a value in lieu > > of an out-param, some versions of gcc completely ignore the operation > > performed by set_pmcr_n(), i.e. ignore the output param. > > Filed a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116912 > > I'll report back if anything interesting comes out of that bug. Well, there goes several hours that I'll never get back. Selftests are compiled with -O2, which enables strict-aliasing optimizations, and "unsigned long" and "unsigned long long" technically don't alias despite being the same size on 64-bit builds, so the compiler is allowed to optimize away the load. *sigh* I'll replace this with a patch to disable strict-aliasing, which the kernel has done since forever (literally predates git). Grr. diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 48d32c5aa3eb..a6f92129bb02 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -235,10 +235,10 @@ CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ -Wno-gnu-variable-sized-type-not-at-end -MD -MP -DCONFIG_64BIT \ -fno-builtin-memcmp -fno-builtin-memcpy \ -fno-builtin-memset -fno-builtin-strnlen \ - -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ - -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \ - -I$(; Mon, 30 Sep 2024 22:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727736509; cv=none; b=hxFhAp3dsr8TiPXxUvUhu38qniWv5X2Fdes7Maqk8IMMy0LSNjyggV8IPISTJOpVm4Myybuawmr8Fit/sU6iw5JAYnHBXrSXxsv35OqAIVm2ly14DtFecF1vAVespl2jG0YNsrC6vaJF8j3KBeB9LBzUFsp1Ub/udb/Xp1raeE8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727736509; c=relaxed/simple; bh=S2Z1JwX1MU6DLUEoEGwV8nRjiTHOC576ZcrLMcIfVj0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=TtXR1T34HM5oU3ztoXnoowD7azjdVJnTPQa571O0svHBIOaZbnuKXfVrB7BraowD+v+1Hhb8aqc9omvaP0eu6Nm0NH8FL1LRcOAY/NM6GJDEAQC5GecB+l/CTfM9vBXwwCWWzD/Sg7/hUm7tqzS2Of9O8aGmJs2EGbCQ80Anxb8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=q3Hxchp/; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="q3Hxchp/" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-719064437cdso5563483b3a.3 for ; Mon, 30 Sep 2024 15:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727736507; x=1728341307; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=XEKROrbsF+Qc32qai9a0qLWUFdx11pYvvS7Yvup4cZY=; b=q3Hxchp/yabyxR8sxLQ1wvjZw517OcZbIWReUFnDvyUcy7BUyUG4zzkDmY+F+3dxpB 7x0yn0O1947629aF5TokYUSfDHSgUApASANI8eJ03DGVVeDL2LIcfHK/IpCcEEfS8O5W s++R3uCDarrmtxA3QNH3rIVQ7k1nmFmsvIsKvzWotM0L6LDCT0YR5+C1/ib8eygDygDv Sst//R5WZniDZ/Dcw0PZOsxpavQLlomIUwmMsKMm68pxecAzIlzZ6YsSOwZpW+Wugy+5 Gt/jBFB4RWvXzUXgYrYAU5MTHR4zDr9wt1XoT9CjcyASrj9gtMp6B5cLmF5hISVPywy4 eoLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727736507; x=1728341307; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XEKROrbsF+Qc32qai9a0qLWUFdx11pYvvS7Yvup4cZY=; b=gxmEL7d1thxiGkjLrvCwa+/RfhMQeq/Oe5f48XoZg+laXpMSqazsdKXea4rnxD+6f2 P2ELyk9lA+HAaY+PJqg+C3MWLHlyKtekdTE64X67pr+q9s2KNjLR9qDmPJxBNjXSEIzN jLtyBlBc/TjtDcwqF5oVBeJkEdj0B2ny6pXzwFTVoVAu2w9Zap/zo6IpRkEohOBkWheP XF81LPqcPYTZay0XPMbYmQgN4ZAL74JAwftPNEBmFLBQ4cptATYd64Kz7rmcMt+z5AfJ 8FTj4Ljk84cfaSrHfWQg63Y+fAN2IUeX7iatHBIlfntfO2Z3eW7fFzupTdhxC0bxetPd 7g4g== X-Forwarded-Encrypted: i=1; AJvYcCVJ7ZYrBMkcV6pnKDbKQB255X/bVJugOwfYtN4mZb8NRsSMPKGCm+bgZ28NlouhUl2lNNU=@vger.kernel.org X-Gm-Message-State: AOJu0YyUYO2Y7OT4THPmW7bx4UxRN2kqYOhoSaRfXi8H7BU6uMO3Xkoj kW9iRtW+82O9I6pqvWP1i6OritK/9rx+HkG8n40frhqjul00kssvCGPevvvzb5B9eFI3hIeP6lr 0uw== X-Google-Smtp-Source: AGHT+IFBqE4b3ETKHUb3GkTpAmeIZlaPPTKak751rxnBHWeoFOgyWmnqPX8beCCGnb8n0RirfB1L8PS0CMc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:aa7:83ca:0:b0:718:d8af:4551 with SMTP id d2e1a72fcca58-71b25f2ca30mr23827b3a.1.1727736507148; Mon, 30 Sep 2024 15:48:27 -0700 (PDT) Date: Mon, 30 Sep 2024 15:48:25 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240911204158.2034295-1-seanjc@google.com> <20240911204158.2034295-4-seanjc@google.com> Message-ID: Subject: Re: [PATCH v2 03/13] KVM: selftests: Fudge around an apparent gcc bug in arm64's PMU test From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Anup Patel , Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, James Houghton Content-Type: text/plain; charset="us-ascii" On Mon, Sep 30, 2024, Sean Christopherson wrote: > On Wed, Sep 11, 2024, Sean Christopherson wrote: > > Use u64_replace_bits() instead of u64p_replace_bits() to set PMCR.N in > > arm64's vPMU counter access test to fudge around what appears to be a gcc > > bug. With the recent change to have vcpu_get_reg() return a value in lieu > > of an out-param, some versions of gcc completely ignore the operation > > performed by set_pmcr_n(), i.e. ignore the output param. > > Filed a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116912 > > I'll report back if anything interesting comes out of that bug. Well, there goes several hours that I'll never get back. Selftests are compiled with -O2, which enables strict-aliasing optimizations, and "unsigned long" and "unsigned long long" technically don't alias despite being the same size on 64-bit builds, so the compiler is allowed to optimize away the load. *sigh* I'll replace this with a patch to disable strict-aliasing, which the kernel has done since forever (literally predates git). Grr. diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 48d32c5aa3eb..a6f92129bb02 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -235,10 +235,10 @@ CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ -Wno-gnu-variable-sized-type-not-at-end -MD -MP -DCONFIG_64BIT \ -fno-builtin-memcmp -fno-builtin-memcpy \ -fno-builtin-memset -fno-builtin-strnlen \ - -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ - -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \ - -I$( X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFAE0CEB2CC for ; Mon, 30 Sep 2024 22:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:Message-ID:References: Mime-Version:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eN1zsNKp4walppgaxA2cVbuC4e6Yph3Y5gooKRjmMJs=; b=X8YCYNIffpDs0d 5FT8hkqQAtOp61Xo4NDnOVhoLoMpnmGAiGhn+/6HI/iGC+iqA0t/4inrAz9Zbw5NnWq2zsoul0Kgr THmfbFGN/w8KqfvXCHrCpG53IL/C4GaAsvSp4Cvfor5D+UDj3khox+QovFy6vVTNegShCMtA5wPzp +C02S+mpRuZr7DtxBU3tWpcPj+dfQ45kJkwhgWQoKBMeMo2rPEh66yFAwy5oh4FnPUmB2e6PPVNmG nkubOkFp0fcnPv30+gJrpxsFqy1FFJG8w7WBfjjh7m2QXzol2r0k2gX1DwbodC2+FMfc81J5N+x4X h/WIp6Ywaj7PH0ebTQnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svPBw-000000013ZV-45n6; Mon, 30 Sep 2024 22:48:32 +0000 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svPBs-000000013YH-3UPN for linux-riscv@lists.infradead.org; Mon, 30 Sep 2024 22:48:30 +0000 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-7178388a8b8so3430860b3a.2 for ; Mon, 30 Sep 2024 15:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727736507; x=1728341307; darn=lists.infradead.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=XEKROrbsF+Qc32qai9a0qLWUFdx11pYvvS7Yvup4cZY=; b=ly/H4gcG/uPQHPv0EoRxCMyIg8ITLC2XVYbhDe285BhIBQ2gEuUeeZA2FNqhCtPs2n DtT51EXCXHcNVP83h1tZYNDmiTGy5YjYxX8nGa6KsBNNU7VdUyk0X+Km/0qM1jf6xAhA dGC2TonXpHwDi9N6BF0IDogulEBbkaGvyXdPfaE6PrNM4ideBZxnEAZo1xyqyNNZ/HU7 s0dSV5hI0QuHJ6KBy9GbmpNRtDzJlqnBs9t7uZ6ASx3616ATYLf4jax2u6Nzg1uA2lGK xDeYaY5FITBJQI4sCNtJt+UmGSb7CVmZn0dJ6DuTXNtT7QNJpMz/BUzwu1ay6yu4vbZN VkYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727736507; x=1728341307; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XEKROrbsF+Qc32qai9a0qLWUFdx11pYvvS7Yvup4cZY=; b=HyS7GAULuhNVVze+wD/tUqJZwpeAHYwVjZKFogGuZ0ngBAl6dWQPj+WQotroZ3vjjf EQwS2rWX/Hi5eUtTZXFlvMdMTyQ+nDRDklVfgAXZ/OoB2E9h7aesFOBqIsEzflF5biJK cizaajyKaLekgh+LkUbGmWz7ovzmpeZhw5pP4nYWpPgIyU1onkkzklJEsQNlKISw3kUU yXiev9KnSLESi+rjy7BcQ91AryVXs/1zHRHaIRJZd9dL0IMaoCRYjZlMFX8bNDcGSXWk elH6XFPLy6A+B9+szUU77Mrxa+I8RM+I0bSaDZAW73QnnGwxU2K/bQbx10snvMiwMAHM 3jyQ== X-Forwarded-Encrypted: i=1; AJvYcCUtGaEz11HK5mMzor4SvmxN0rM8botd9BiD6ZboPApoyvBS1SWwAim0T+Ysh7F12JDzelc180bLNOQd6A==@lists.infradead.org X-Gm-Message-State: AOJu0YybHrGyoQWbbLDGLEJGnZ9oPjye0GeIePUcgPnLIM8/HUGAwJ5g yKZQKffw+OvQhPgON8fSbt9wa+TC2Vb5qmzuDzoK+h/F9SzduRJ1fKOi0pFwKQySyR2LKi1Qaqz kyw== X-Google-Smtp-Source: AGHT+IFBqE4b3ETKHUb3GkTpAmeIZlaPPTKak751rxnBHWeoFOgyWmnqPX8beCCGnb8n0RirfB1L8PS0CMc= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:aa7:83ca:0:b0:718:d8af:4551 with SMTP id d2e1a72fcca58-71b25f2ca30mr23827b3a.1.1727736507148; Mon, 30 Sep 2024 15:48:27 -0700 (PDT) Date: Mon, 30 Sep 2024 15:48:25 -0700 In-Reply-To: Mime-Version: 1.0 References: <20240911204158.2034295-1-seanjc@google.com> <20240911204158.2034295-4-seanjc@google.com> Message-ID: Subject: Re: [PATCH v2 03/13] KVM: selftests: Fudge around an apparent gcc bug in arm64's PMU test From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Anup Patel , Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, James Houghton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240930_154828_877213_ABB7455C X-CRM114-Status: GOOD ( 15.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Mon, Sep 30, 2024, Sean Christopherson wrote: > On Wed, Sep 11, 2024, Sean Christopherson wrote: > > Use u64_replace_bits() instead of u64p_replace_bits() to set PMCR.N in > > arm64's vPMU counter access test to fudge around what appears to be a gcc > > bug. With the recent change to have vcpu_get_reg() return a value in lieu > > of an out-param, some versions of gcc completely ignore the operation > > performed by set_pmcr_n(), i.e. ignore the output param. > > Filed a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116912 > > I'll report back if anything interesting comes out of that bug. Well, there goes several hours that I'll never get back. Selftests are compiled with -O2, which enables strict-aliasing optimizations, and "unsigned long" and "unsigned long long" technically don't alias despite being the same size on 64-bit builds, so the compiler is allowed to optimize away the load. *sigh* I'll replace this with a patch to disable strict-aliasing, which the kernel has done since forever (literally predates git). Grr. diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 48d32c5aa3eb..a6f92129bb02 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -235,10 +235,10 @@ CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ -Wno-gnu-variable-sized-type-not-at-end -MD -MP -DCONFIG_64BIT \ -fno-builtin-memcmp -fno-builtin-memcpy \ -fno-builtin-memset -fno-builtin-strnlen \ - -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ - -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \ - -I$(