Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp779995iog; Wed, 15 Jun 2022 12:08:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sm8R/ssXaC1Tf8v4QsjhjKZ+XRC8bzJlAtA73AlKr+MdVuYvJgJNmRhTup7IXvC6oRJtG2 X-Received: by 2002:a63:3184:0:b0:3fc:5893:c866 with SMTP id x126-20020a633184000000b003fc5893c866mr1136591pgx.56.1655320115186; Wed, 15 Jun 2022 12:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655320115; cv=none; d=google.com; s=arc-20160816; b=BSwdiwtBfHiVzHOXncMxpppVf2GekymO4bWncBl37t/QNq0i3eZjdrST85grZXp/ke aBdPQR8E5hmaJElj4jjkhyTyT/dE7d+fWZpw2FCHozSRnk8z5uazERAC9E2BYRwH1Ssj uNoFIrbFQ8HT+iORJsV5S2pK7yBTr2zDdrzHKt1t3WzzABy2EZ9ixE6AxBDqe0qcqV9h AecTfHU9MqgFHWbi+ztgXqTNUw1KAf9iDfJ58Vw0v8ckgsVtgq0W7wxNxLMOnAIPfSOf 6XbgMSgUj55tfclWuxH2h9SgNgOhzQ7r+jaRP0WyuO+5h3fvg53UzbYAgLd2sTXKMKCY o+vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=JOfZ+gB0dYMw5zlfGsNpFQnCHYNIGhGPLB/fJ5JUiU8=; b=u4OdpUJRYli5kPLeC7aEhrZNTkYXVHFBIYUXU4Vs4UZZlxe8DzG+Iuk/xvsTLPxHTA i2jciplbTHEXUq0Ve0jovWzg2g+a24V3zaF29xvu/MQSB+oSUf4Uve5Qraf07KxpCbLf CpVYGe+M/CN2YyYxBOWIVYiTELmncTLS4Wv+5xxbj+plF4Paqyqd/IlDFXm+LTeyPjCc MLLxuZ2T7WlbR9axybrz1b8PA05pqe2TNpKXscmhPqYe8kPSsdVJTWEaEDb4NtDYGRUs xPA+HTRnNrE1qSQQ6b9sbBq9s5/zjfKZcqo6PW5PnLmm3Rt6XoJYewlAEEoZRCDpwobj PpdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SmOp6Z2z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a170903024900b001620bc89356si6296549plh.482.2022.06.15.12.08.21; Wed, 15 Jun 2022 12:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SmOp6Z2z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231737AbiFOS5V (ORCPT + 99 others); Wed, 15 Jun 2022 14:57:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349137AbiFOS5S (ORCPT ); Wed, 15 Jun 2022 14:57:18 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 676A541F92 for ; Wed, 15 Jun 2022 11:57:17 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id y15-20020a17090a474f00b001eac1991515so1435966pjg.1 for ; Wed, 15 Jun 2022 11:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=JOfZ+gB0dYMw5zlfGsNpFQnCHYNIGhGPLB/fJ5JUiU8=; b=SmOp6Z2zPaMf+7HW3xlQs45Fjh1wQY3JcE955U5EzRHsTUkE/IVL5RlhOgVgPtTUSd 40TLB+kwbienuX8Dx2E0wGxELrUEYzz+rLJg+3O0i9zwkTixcET9vp4JBVjxgbrJBAnu +cYumohJ/0Z1hODaPf0Ii6qP1SyuhGSKXz4inlCZbL9c2knCQta/33jC2LQmQ/aeD1/y Tnpe70f0H+Jx5LGBbpe/TeG9QpvYq8ogcKYRc6PcX+ZPg4yqL5EsPmDFbBWLlmCrK4+l wTu6a0wUtxmkc1JTA20jJsnPffMTnk8/bBUa5UdrL8N2SVS1KlYBk5kkxZrRKRWiYilI BvRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=JOfZ+gB0dYMw5zlfGsNpFQnCHYNIGhGPLB/fJ5JUiU8=; b=XuXFQq/MobRm8eIUdVDMVcIVAyk540u1ZrtUFwiP1WkR+nalqPCTXb4vNsOq7LWEgK Avdjj5dx1W/G28DrDrTfjCYqYHxc6mKfExdr/t2gD45U1oGVG7j6i1davUwryhwVrR43 rEMTDI8yVK05QaCazBlRqAIu5RiTqHf1rZc+TcMlVGfTQVxCgMXRHFTQk6KIBBkeSHkD HqagYzQ/rBWTTg8w23S2v4hNKBIrr5+nyvYvxxTWgChNjPbujIx5RaKdLGuVibIpiQFW 4rkk5zZYIqPn9CRC8Zas8BJ5Xmc0dxJ4wOKCpykduksEkWwUO19MhBVt4Su6gCiHwyhO 1hQw== X-Gm-Message-State: AJIora9NIZ5eRbP3s4ZTqcrQTfu6/iAb3p4wI1SOof9aFNnG0XbEEEhs tx0FNya88KK0XjBNNzi1oHiGPtuKst4/ X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a17:902:74c3:b0:167:6811:40 with SMTP id f3-20020a17090274c300b0016768110040mr1022512plt.120.1655319436857; Wed, 15 Jun 2022 11:57:16 -0700 (PDT) Date: Wed, 15 Jun 2022 18:57:06 +0000 Message-Id: <20220615185706.1099208-1-rananta@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH] selftests: KVM: Handle compiler optimizations in ucall From: Raghavendra Rao Ananta To: Marc Zyngier , Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose Cc: Paolo Bonzini , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , Colton Lewis , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The selftests, when built with newer versions of clang, is found to have over optimized guests' ucall() function, and eliminating the stores for uc.cmd (perhaps due to no immediate readers). This resulted in the userspace side always reading a value of '0', and causing multiple test failures. As a result, prevent the compiler from optimizing the stores in ucall() with WRITE_ONCE(). Suggested-by: Ricardo Koller Suggested-by: Reiji Watanabe Signed-off-by: Raghavendra Rao Ananta --- tools/testing/selftests/kvm/lib/aarch64/ucall.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/aarch64/ucall.c b/tools/testing/selftests/kvm/lib/aarch64/ucall.c index e0b0164e9af8..be1d9728c4ce 100644 --- a/tools/testing/selftests/kvm/lib/aarch64/ucall.c +++ b/tools/testing/selftests/kvm/lib/aarch64/ucall.c @@ -73,20 +73,19 @@ void ucall_uninit(struct kvm_vm *vm) void ucall(uint64_t cmd, int nargs, ...) { - struct ucall uc = { - .cmd = cmd, - }; + struct ucall uc = {}; va_list va; int i; + WRITE_ONCE(uc.cmd, cmd); nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; va_start(va, nargs); for (i = 0; i < nargs; ++i) - uc.args[i] = va_arg(va, uint64_t); + WRITE_ONCE(uc.args[i], va_arg(va, uint64_t)); va_end(va); - *ucall_exit_mmio_addr = (vm_vaddr_t)&uc; + WRITE_ONCE(*ucall_exit_mmio_addr, (vm_vaddr_t)&uc); } uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc) -- 2.36.1.476.g0c4daa206d-goog