From nobody Tue Oct 29 16:22:55 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 4XdFsr1VBnz5bdyq; Tue, 29 Oct 2024 16:22: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XdFsr0yf3z4kkT; Tue, 29 Oct 2024 16:22:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730218976; 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=wABG17vmEAo0ToFsP9NEdoX3NHSJjoJdS34hOlRmKAQ=; b=k4sjxApR9X+z9w1SRRbJCI9lFE+aQZs0sVA0fYruPTqLDjZlI1sysjamccq3d23vHIyzSx 7+wavVM1vtqN0uQJOZJwQWTXWLZlrNfxZeL3kUZ64v9SDwNNmpIgNZfCYoAVXkwTqtxGBo eh+3O1w+XHYNf1AaYVnKH7dkkdbquZMGi1mw6ZIJVzrMfKY4ejAqmOEY0MJntA8Frtxj8t HCDEOQ7sKifq3zDl7ZKnp8nm3349CG8K4BLI6EjDfykFOn+FUJGdSRvEk94u9uPcCAo4Sd 8A0PCD+KTQHjWwMdsM/Jqde7dzByRw0Bcxfnq8hPvbXGmaVp+jasDiViv+3vEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730218976; 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=wABG17vmEAo0ToFsP9NEdoX3NHSJjoJdS34hOlRmKAQ=; b=gVp/z4LvlvpXJR8A7O7ttgsJRu9TZ+83tSXBtse4slZgO9d8GwwKhCDASKXn3z5f8z0/A+ VjBwLjKV/FvQ6gge+7xAQaCqiScghVNeM7tVvfKsXJrDZA54QSS4qGWhY8z/QI6qxn/QJb uq1JSgjZ9YZhwY3QHzdg/eRYBzMt9A/yvv6bclajVWX/vzWPua5WS9EIIFbA/yIk3C/84h AlyVGlrsSq3gn7foDewrUix6PxZGype0Lf7pL//eSAi/I14VNiZx8wF8oU01Jr4vp4LoPL 9fiD4jcNU0cei/DvCYg6r9EpurWut3nOiigtjVI4Uz2MFlGogrgnz3pwiKGp7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730218976; a=rsa-sha256; cv=none; b=TxFaDIBNR1yFuPGsHWbh8Ua8rXavWTPXfDuyrjuCfBN65lEtBeYMSuRh/yTdf/dIUNXBem ZWcQVYX+E/RdHOBb2P5vN+NxNKON3zZO2XZii9yWwFqfrE/ke9xGF4lJJLdFVP9jyFch6X G2JkXrG3Zcp5OQ5yBO2F3PpSWQzjUu46xERAj2kea14g9t5upekikysjovmMu0tmC3OnDq eulbQvjLcsUqc3zK4Uvj7RbpTz1nEBTIM5h+SRhitjyiXgYCfPAymm2UYcNrWiY8eFxHTp zLKYqTcSkRqm3aXcPwOPTvj5i4O/GgA8YmjPf5Ome8hIV8ELlkG93O9Yeac6hA== 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 4XdFsr0YrNzX0R; Tue, 29 Oct 2024 16:22: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 49TGMtP5057143; Tue, 29 Oct 2024 16:22:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49TGMtrE057140; Tue, 29 Oct 2024 16:22:55 GMT (envelope-from git) Date: Tue, 29 Oct 2024 16:22:55 GMT Message-Id: <202410291622.49TGMtrE057140@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ruslan Bukin Subject: git: 72ae04c73347 - main - vmm: fix vcpu atomic load 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: br X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72ae04c7334743c0fec2e8c99ac13fd8ca63f51b Auto-Submitted: auto-generated The branch main has been updated by br: URL: https://cgit.FreeBSD.org/src/commit/?id=72ae04c7334743c0fec2e8c99ac13fd8ca63f51b commit 72ae04c7334743c0fec2e8c99ac13fd8ca63f51b Author: Ruslan Bukin AuthorDate: 2024-10-29 16:19:03 +0000 Commit: Ruslan Bukin CommitDate: 2024-10-29 16:19:49 +0000 vmm: fix vcpu atomic load Load vcpu with acquire semantics as we are making a critical code section between creating vcpu and using it. Tested on risc-v only. Pointed out by: markj Reviewed by: jhb, markj Differential Revision: https://reviews.freebsd.org/D47306 --- sys/amd64/vmm/vmm.c | 3 ++- sys/arm64/vmm/vmm.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index 12ebc1671641..07d3f74b8365 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -559,7 +559,8 @@ vm_alloc_vcpu(struct vm *vm, int vcpuid) if (vcpuid < 0 || vcpuid >= vm_get_maxcpus(vm)) return (NULL); - vcpu = atomic_load_ptr(&vm->vcpu[vcpuid]); + vcpu = (struct vcpu *) + atomic_load_acq_ptr((uintptr_t *)&vm->vcpu[vcpuid]); if (__predict_true(vcpu != NULL)) return (vcpu); diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c index fe5f43495262..4127fad5cd59 100644 --- a/sys/arm64/vmm/vmm.c +++ b/sys/arm64/vmm/vmm.c @@ -443,7 +443,8 @@ vm_alloc_vcpu(struct vm *vm, int vcpuid) if (vcpuid >= vgic_max_cpu_count(vm->cookie)) return (NULL); - vcpu = atomic_load_ptr(&vm->vcpu[vcpuid]); + vcpu = (struct vcpu *) + atomic_load_acq_ptr((uintptr_t *)&vm->vcpu[vcpuid]); if (__predict_true(vcpu != NULL)) return (vcpu);