From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 134903BB105 for ; Fri, 26 Jun 2026 20:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782506022; cv=none; b=cfQldqYCdt0fzlcCb7ybVe0dA1OuzJYGMIAe0jDQKCmu2Py4KLaoyjdLBkshsIeKKLo6/ttoUEIbxq4zTLBGs5rOwnPj09sAf90jy43g23+gf83E60YuUuXZ6/5Xy00vTbnRAi0UKYQwguRAI1tssfLUhBUvMk6F70QXX6EJWU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782506022; c=relaxed/simple; bh=USYMI9QR5z5OM3vpjNXG3YIprL2aTDVo5aYeeTAelic=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References: Content-Type:MIME-Version; b=UWZVCLEC9HSOiobuyzen91QlLXJ7Clm8AVHgPUPO2jzUjk8yvh8GNmCmzIR4kfSz06ECaHAmlplNWpxwaONSdlHoxqJunehx6naOuRucT97YggKgTblNUi39IyX67PnEV5SjOEosydMeWGHOHiirkGklHIkygpk9yIKiNk1VG68= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=C8UODyqV; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=IBRTSpCN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="C8UODyqV"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="IBRTSpCN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782506020; 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: in-reply-to:in-reply-to:references:references; bh=timVrrMf52BZR/USmcM0cBFD14tn00ZiPE2meAEf2r4=; b=C8UODyqVMBI0zkjseVjpM2TPsrSi8V0fOsT5qj9SRAuyB4MoBBH4RZ3cLKCEvp7q2Lba8B y/YfRHBawbtv8CNIkgp6U4EEgYYU9yjm3FEalSf0cKJrCKaZ4JJz4AdqJRryzSQfNisCnO ZPdRmnMX8MvmrxZCh+eguDzDvsh549E= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-eXHs8HpYNc-YuTbxr5WL4w-1; Fri, 26 Jun 2026 16:33:36 -0400 X-MC-Unique: eXHs8HpYNc-YuTbxr5WL4w-1 X-Mimecast-MFC-AGG-ID: eXHs8HpYNc-YuTbxr5WL4w_1782506015 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c122a8e4952so95512866b.2 for ; Fri, 26 Jun 2026 13:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782506015; x=1783110815; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=timVrrMf52BZR/USmcM0cBFD14tn00ZiPE2meAEf2r4=; b=IBRTSpCN3N//Zs8hLIVZQRa3B8nFdwwgKsOhHdNKgN3DkKSgH9u2ZYOqGqWflhDyc7 lbPl2p2z705bzyF9ijqak2dEQW5gF/Xf9Vnw7rKxqmqLYMEPYreiGcX7FEAZjYI6o+nF eQ2o2ANvwl7MiBem2EgvavqKJu7keO3yvDo/Z6msztvJ2Tj0Ko7B6QwPa1VgUxI5dnZJ 5z6hX0BhvtolfgzH/3Elsk6rd0X5n8//1NaFJ9H1Q0NsiFYSez2rUawKMUg3CfTxQtTf Ki5CRpl4lDi2s7OwNaYcU1N7N4uFQeYc32C/qnThBLX9fCaX5IxLN72zaAC0+lYMpnmk lCoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782506015; x=1783110815; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=timVrrMf52BZR/USmcM0cBFD14tn00ZiPE2meAEf2r4=; b=s3qwyw9B4MkSbrE3oM1AYG7gJfLUhsqAuSczCvHSXrnlkIAWE+6sJYFaJybr5wU+Qh X9qqUGIHqWIUiQCLnD6WXdirSWH4GkJxB3zbnN48PDWRwn6MWHlLIDfD6F6z/i62peIA Fp0auhwWqhOqRYE6KD0DfQ5WBJWTn1CuRK6Unx4QbCIW79dYWMkg4NJ3I2reA+7iZ2P/ 6TmYQXlscldMDQ8/kxzbEOs+unWxfwSz+r5+t333SlA7HGRwpuNSW5qDVVGoj7VCp9S+ NlpkRmXPqHfEVOmhPQ3xVmo0WbMKMSa+O0FbJoB2MKaUWrnbDt2jMEj8TGDiKh7jrgwf oHAw== X-Forwarded-Encrypted: i=1; AHgh+Rqh6pHrro8OvZnt9KzGp5fCLjo9V8lsrMSC0akz/E9nhOzQAgZzNmGT5o8gO+gZCJOd9L8seS9t2eYo3Cs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9umst2fYfdqADeL/1MYLee9mbvPO1C3fjd+L0kfRDaqZVbIbR rtvphDVPSVBokswoPyhYpnD9XIqlbq5SP1hob15vodKvw/0sSnTVx2oySV1F8MnNI611NX4k/3o RKc90IcVK6C5u8vVRNpim98OBkp5yUdyzexgRYC4XSS8f+L16g1ZphbngyumGF5K0uQ== X-Gm-Gg: AfdE7ck3lDSna7ydHRCHbnqHBxIBeLHPDzwWTRqiFGM0YNqSiZUYpmVhdScFa56xcuL TaHn0EMA50wge8phZYWl70K/JHLgEX8MNEq/juO1XICAsntmNDqJzoKoarqgfdGkv05N7q4iLTO 7jF46hljiZXH0NmDUzTf7VJLyE3gAPEV6LJO8CeXVE0yYEU6k3Lli3cndJBE5fiEhycRCcjOiE6 TGLSvNzpYJLuS3HbPKP2WIzkUSDH/nWHJEl5w9k8TL8OJAxd2pcwBrQSZ4sLLDA9JfWPKdw1ZhW Wnt5/vIMCTI7Q98PWbdx1LTFkaw1QFE9/Ang7VeEM/8PHVAoarH9CJ+zdtVmFAzfxQYs60ch+Ak gwvmcpg1TTxlsOGkZ6s5Vo5a/q0m87bMmer1aKiq5T6/5zy8IpIbhkvrFet5/Bw== X-Received: by 2002:a17:906:4fcd:b0:beb:133d:cf02 with SMTP id a640c23a62f3a-c12335f0e84mr123278966b.26.1782506015345; Fri, 26 Jun 2026 13:33:35 -0700 (PDT) X-Received: by 2002:a17:906:4fcd:b0:beb:133d:cf02 with SMTP id a640c23a62f3a-c12335f0e84mr123277166b.26.1782506014859; Fri, 26 Jun 2026 13:33:34 -0700 (PDT) Received: from ?IPv6:2a01:41e1:15a2:6900:8439:6748:6ff7:9b5e? ([2a01:41e1:15a2:6900:8439:6748:6ff7:9b5e]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1220e697d3sm158744666b.5.2026.06.26.13.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 13:33:33 -0700 (PDT) Message-ID: <03245373bd3912bb7421b93c383c9e07454aadd2.camel@redhat.com> Subject: Re: [PATCH v2 1/2] x86/msr: Document I/O-like MSR semantics in /dev/cpu/*/msr driver From: Tim Wiederhake To: "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org Date: Fri, 26 Jun 2026 22:33:31 +0200 In-Reply-To: <20260626202323.1169433-2-twiederh@redhat.com> References: <20260626174037.1128563-1-twiederh@redhat.com> <20260626202323.1169433-2-twiederh@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 (3.58.2-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-06-26 at 22:23 +0200, Tim Wiederhake wrote: > Explain why msr_write and msr_read do not advance the index. >=20 > Signed-off-by: Tim Wiederhake > --- > =C2=A0arch/x86/kernel/msr.c | 3 +++ > =C2=A01 file changed, 3 insertions(+) >=20 > diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c > index 4469c784eaa0..cc719a6b2ba3 100644 > --- a/arch/x86/kernel/msr.c > +++ b/arch/x86/kernel/msr.c > @@ -13,6 +13,9 @@ > =C2=A0 * and then read/write in chunks of 8 bytes.=C2=A0 A larger size me= ans > multiple > =C2=A0 * reads or writes of the same register. > =C2=A0 * > + * Writing the same register multiple times can be useful for MSRs > with > + * I/O-like semantics, e.g. a virtual MSR that accepts logging > information. > + * > =C2=A0 * This driver uses /dev/cpu/%d/msr where %d is the minor number, > and on > =C2=A0 * an SMP box will direct the access to CPU %d. > =C2=A0 */ I think I did something wrong with git send-email. The cover letter got lost: [PATCH v2 0/2] x86/msr: Clarify and restrict /dev/cpu/*/msr read behavior This is v2 of a patch originally sent in May 2023 [1] and resent against v7.1 [2]. v1 removed the loops from both msr_read() and msr_write(). H. Peter Anvin pointed out [3] that MSRs with I/O-like semantics (e.g. a virtual MSR that accepts logging information) make the write loop useful. This version splits the change in two: 1/2 adds a comment explaining why the driver loops over the same register, so future readers don't have to rediscover the rationale. 2/2 removes only the read loop, where repeated access to the same register is less obviously useful. [1] https://lkml.org/lkml/2023/5/23/1230 [2] https://lore.kernel.org/lkml/20260626174037.1128563-1-twiederh@redhat.com/ [3] https://lore.kernel.org/lkml/33F430D0-EFE6-471F-B4A1-D5D20E1F65AD@zytor.com= / Tim Wiederhake (2): x86/msr: Document I/O-like MSR semantics in /dev/cpu/*/msr driver x86/msr: Restrict /dev/cpu/*/msr read to a single MSR per call arch/x86/kernel/msr.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) -- 2.52.0