From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89B93330666 for ; Tue, 30 Jun 2026 22:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782860199; cv=none; b=tJp2wEgtX7BNp5jDtNbbv39r6LGmybF+hAdySDOtwPM6CrHUUMdh6ST5iaU4KEeq5sXOux8MZjwoOWW68VfUT9p6Q1BOQv/YDlW1sJACauplv++SDrZROjeDkd92KZIuQxSuvGeeBx977E8T/DdJF4nlkwZTox7cGk0KV77lcSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782860199; c=relaxed/simple; bh=tkgAWenidxTobeaXVYo+mMrBXgxtirWy7FTikA/UKtM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rA3BTtxWuDQfMvOorSjhOEJHk7VwnIcfQWRoTXHUYa8kSUQQiOyesGRRHKK+mzDuOjRzYNYRNz/M90UiFx6d9aNLoYydo5L2JPr0k14HGONZ5Zm6006FgCImxH8yBs7R1C7HkMcuDjVWx4kGL6u3GETtg+3GnihVF6UkXONDPH4= 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=E8Srj2Wh; arc=none smtp.client-ip=209.85.214.201 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="E8Srj2Wh" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2c9e9cb6a44so366805ad.2 for ; Tue, 30 Jun 2026 15:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782860193; x=1783464993; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=rL8s0hiiR/lgasxkfz+QkDIPhc5NRPLZb5qejoLSFFI=; b=E8Srj2Whr+u9zfORboMvaH8Ta9QsJjUL2QgHEHzob2/urR3Yyp1CuRBGYE0OHwJYwe 4cLIerMsUT69z0bk+V4Z+Rl749z0AJIB7ktjhs8qwls4KDc968sL/jFb6+Ft+938sb5v 9vQV9sUVzh1se8MD4wzyKFlkhJ7ULOTdS13qn8brnCUHtm4MFWTj2QQyQmyzRiGU7Hz5 ki8pk3SMq1Uuw8ol0+3m+2y2g9Vfbz61zkU2Qw18VISZd1OPBA5eZwg1uLLYVco9Yiib kab3ikMCmj0D+sdaNujtRXFBPzvB5Fh1UjSt51VeeArsdh8i3Hb1LeDDUijm/dTd9DvT k2CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782860193; x=1783464993; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rL8s0hiiR/lgasxkfz+QkDIPhc5NRPLZb5qejoLSFFI=; b=Fx4fFFJJBYmOriKEu5BW77VZIuUlquXJGPyQXRpAcyed2YwXqGskPFgdf4Mi7MzW4N N3i5sHwP+ToCw61CYPiAsAAOdFboOzjK06JfVnIv6g1xw2KeHEy7uXtmLvDAEZs0VL1+ zBgObikmLJzZBqoDzvRumTcRWTQuHn3VPNOdlJjLZUyHlfD1udZKOAk/RqQsB2N0CdO9 ybwmlpbmBkVDXv5Ffz5p8SjgTH/G4ZHOXobWPwXrsdBUHIKK3mfdkfYFogImouWeMWvx JRoxa9q6co4jLqid1wrYXgGJNsV2Wtc7tO6IeQdfB8WBymo4ti0S6aJ4iZtgg1uE336T 12wg== X-Forwarded-Encrypted: i=1; AHgh+RqDeQG45HWXoV4vHJMKzZnrWb0YkTS6/OCSrxe6gwoB/FzhaszGPu++2h90HHE2t+2HMUdZpHfj6AdpedU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9+pTgUNLpdxoba6PnZXLhVGZESLeoqWKD4vsQD/iYPWaVDWf2 v0Xw42to1WUJ7yG7NR2pQwpdaoBMdGwhrC96EkLjxdDyR6kA80ORr34oIF53qgzuM/vDLxlxbIO oK+V70A== X-Received: from plfn8.prod.google.com ([2002:a17:902:e548:b0:2c9:b419:c25]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1111:b0:2c9:97a8:aff4 with SMTP id d9443c01a7336-2ca2ec301f4mr46392185ad.45.1782860192643; Tue, 30 Jun 2026 15:56:32 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 30 Jun 2026 15:56:18 -0700 In-Reply-To: <20260630225619.511632-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260630225619.511632-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260630225619.511632-12-seanjc@google.com> Subject: [PATCH v4 11/11] KVM: x86/hyperv: Use {READ,WRITE}_ONCE for cross-task synic->active accesses From: Sean Christopherson To: Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini , David Woodhouse , Paul Durrant Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+5b32c49cd8f005e65654@syzkaller.appspotmail.com, syzbot+5d2b94b77112148d1744@syzkaller.appspotmail.com, David Woodhouse Content-Type: text/plain; charset="UTF-8" When activating Hyper-V's Synthetic Interrupt Controller (SynIC), mark it active with WRITE_ONCE() and query it using READ_ONCE() in synic_get(), the only known cross-task reader, to document that the flag is accessed without holding the vCPU's mutex. Note, there are no data dependencies on the SynIC being marked active, e.g. the vector read by synic_set_irq() is set (usually in response to guest activity) long after the SynIC is initially activated, and a false negative on the SynIC being active would be benign (ignoring that such a race is likely to be problematic for the guest irrespective of what KVM does). Signed-off-by: Sean Christopherson --- arch/x86/kvm/hyperv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index f765c3bb9b1f..9d38cb644668 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -219,7 +219,7 @@ static struct kvm_vcpu_hv_synic *synic_get(struct kvm *kvm, u32 vpidx) return NULL; synic = &hv_vcpu->synic; - return (synic->active) ? synic : NULL; + return READ_ONCE(synic->active) ? synic : NULL; } static void kvm_hv_notify_acked_sint(struct kvm_vcpu *vcpu, u32 sint) @@ -1013,7 +1013,7 @@ int kvm_hv_activate_synic(struct kvm_vcpu *vcpu, bool dont_zero_synic_pages) synic = to_hv_synic(vcpu); - synic->active = true; + WRITE_ONCE(synic->active, true); synic->dont_zero_synic_pages = dont_zero_synic_pages; synic->control = HV_SYNIC_CONTROL_ENABLE; return 0; -- 2.55.0.rc0.799.gd6f94ed593-goog