Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3312382lqp; Tue, 26 Mar 2024 06:06:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0PIUAyy1PNofj7DVhrhcRKkjwJsV7FouUITemKaCiRasPph8FMEkdxjIVOcIa49dk+nyXkT4cc/3FPI8mKWyR8WQHNqZ2uIHcdN7f2g== X-Google-Smtp-Source: AGHT+IH4SBedCYDL6HVUEzLKVyUg/TGls24X2BhzlvHrcrlGoXrcHLyrtEn4pHJdSUtsw0Qhn73p X-Received: by 2002:a17:906:a0c4:b0:a46:7b92:8d2b with SMTP id bh4-20020a170906a0c400b00a467b928d2bmr7885627ejb.46.1711458403129; Tue, 26 Mar 2024 06:06:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711458403; cv=pass; d=google.com; s=arc-20160816; b=HcQquITrqFD/GhYXMUdB6daq+t/gEIhO0GPWDizNkdjKxCY5a/R5jEwoPH9G6/xElL AYeOCkV/YHtbusGDrHCmno3L5KOuSHXu6EMMaWz7dNnBApm0S160LM005BQmhn5MUng1 Twr3atiT6Wz+sBQtEKpF35Dq0CjCQQ4xxmB7Yun6WY3B9iakv+yE3WZLsaiUFlo2ZzzV eZ70BUpmJ5UqvdusQEQpUl+ZnnAingwD+tVebdUwlKvB+FaYwedvUJ06jUfAWqvxryeL eSvNQhFmxBN0qhnUVkbZ+qmZ3ZGwakjMr73yWyq6nxL3g6ZxuT6pKkRwiUJWbt1t9AZj mrww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:subject :dkim-signature; bh=nXEdpgCUmREY3ofef4i8+nCfBb4YBIpNnsbD0WGVIIo=; fh=5UqLw4CdzXF5VULojb8ofAaJ30neTroLA8ssWgSEaO0=; b=O0RqYD4mfrT1zqAKDsu1mqu6AN+Glgmkjvxj2X51w1AmKbf5vIuQpCeSMK256oq2Wf b0DfZB3DwOIJOIL9VCcMn2op7APimlRsTqQx0mSUbo7fjb+FSdH9y0vbgEV0FK7oQF90 BIb0LZ5CslWSAceD8RUjmxZJiKM0uyOteYAZkqMDM7v4Vo66jWHFKSlYaIZfdy+oDJSj STqPZfwSzjHAHcNHlYMFMGQHxcGjzAlsd7CFUu07wHa3ACjraIwC5tRpn0bUBi83GiPI BoJrOTy88BwtSF6UyMHA/g52BYuhWR3KiroXdjHQ0Q43l6SIpR3DEsfisZ9huqFF5vMb m50Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amazon.co.uk header.s=amazon201209 header.b=TwTZXKoc; arc=pass (i=1 spf=pass spfdomain=amazon.co.uk dkim=pass dkdomain=amazon.co.uk dmarc=pass fromdomain=amazon.co.uk); spf=pass (google.com: domain of linux-kernel+bounces-119035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i1-20020a170906698100b00a4632720e51si3643992ejr.933.2024.03.26.06.06.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:06:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.co.uk header.s=amazon201209 header.b=TwTZXKoc; arc=pass (i=1 spf=pass spfdomain=amazon.co.uk dkim=pass dkdomain=amazon.co.uk dmarc=pass fromdomain=amazon.co.uk); spf=pass (google.com: domain of linux-kernel+bounces-119035-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119035-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A59E51F68324 for ; Tue, 26 Mar 2024 13:06:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90CF37173E; Tue, 26 Mar 2024 13:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.co.uk header.i=@amazon.co.uk header.b="TwTZXKoc" Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) (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 531156D1AB; Tue, 26 Mar 2024 13:06:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.95.49.90 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711458394; cv=none; b=ZmTm9B0dUPiOICcpAfsYLp2SXHpkKijbMo039vEVQXl7TCYx9buu4pITXe25UaHNcAn7bTwSV3CDEmUPI4RbJ4J1lkMFxI7XaJpnEGA7UN5UbUu/rWtryBLmxNTMMnUAWDVxJyocHlQdvXYqSJb1cE4q753weGM6IaLIn5uvKZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711458394; c=relaxed/simple; bh=C1lns0hmF/ZFdYXZmwb6mRMtg+MzMiLPqOEBEcJGeZc=; h=Subject:Message-ID:Date:MIME-Version:To:CC:References:From: In-Reply-To:Content-Type; b=KaFwFZXT+v76rQpj/RQ4aKMgPdCf1lZdvUacf4kk6la61hCI2OhKQoNowzHocHE0q9O0MT9Mu7lrBqqdxYQX+AUD1YpxbpOHaYSnCvRHQybr6FApBk0isom+PxYgSfz8EvCTpKG/IRoaXycC5mlZ1ijl9C6EIbhLfaVW5G5bD78= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.co.uk; spf=pass smtp.mailfrom=amazon.co.uk; dkim=pass (1024-bit key) header.d=amazon.co.uk header.i=@amazon.co.uk header.b=TwTZXKoc; arc=none smtp.client-ip=52.95.49.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.uk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.uk; i=@amazon.co.uk; q=dns/txt; s=amazon201209; t=1711458390; x=1742994390; h=message-id:date:mime-version:to:cc:references:from: in-reply-to:content-transfer-encoding:subject; bh=nXEdpgCUmREY3ofef4i8+nCfBb4YBIpNnsbD0WGVIIo=; b=TwTZXKocRAsPss7Zf4iS5TMjxTCLreIJ4heortT8Vk6MhE6e3iTXVp3w 6bL0ZfvFurIUDtBhuFwRdaZym+ruU2MvxPNc6P5dK0C9AXLr3lA8hKfzw emKl6jHUC+UiV6ZsSWOVzxh2gIk26ZkpAUIUXNcSKl3EmdNXCHu7LIctq o=; X-IronPort-AV: E=Sophos;i="6.07,156,1708387200"; d="scan'208";a="396130015" Subject: Re: [PATCH v2 3/4] dt-bindings: rng: Add vmgenid support Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2024 13:06:27 +0000 Received: from EX19MTAEUA002.ant.amazon.com [10.0.17.79:24510] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.36.129:2525] with esmtp (Farcaster) id fafddf53-9fb2-47ff-8e5c-18a4c6d4f7ef; Tue, 26 Mar 2024 13:06:26 +0000 (UTC) X-Farcaster-Flow-ID: fafddf53-9fb2-47ff-8e5c-18a4c6d4f7ef Received: from EX19D036EUC002.ant.amazon.com (10.252.61.191) by EX19MTAEUA002.ant.amazon.com (10.252.50.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Tue, 26 Mar 2024 13:06:25 +0000 Received: from [192.168.18.216] (10.106.83.18) by EX19D036EUC002.ant.amazon.com (10.252.61.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Tue, 26 Mar 2024 13:06:20 +0000 Message-ID: <96df7e5a-52df-4171-9cd6-78d088a7a1e2@amazon.co.uk> Date: Tue, 26 Mar 2024 13:06:16 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Rob Herring CC: Sudan Landge , , , , , , , , , , , , , References: <20240321025105.53210-1-sudanl@amazon.com> <20240321025105.53210-4-sudanl@amazon.com> <20240325150609.GA3477574-robh@kernel.org> <51403072-f5ca-450e-9206-19ca627ead11@amazon.co.uk> From: "Landge, Sudan" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: EX19D040UWB003.ant.amazon.com (10.13.138.8) To EX19D036EUC002.ant.amazon.com (10.252.61.191) On 25/03/2024 20:41, Rob Herring wrote: > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe. > > > > On Mon, Mar 25, 2024 at 3:11 PM Landge, Sudan wrote: >> >> >> >> On 25/03/2024 15:06, Rob Herring wrote: >>> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe. >>> >>> >>> >>> On Thu, Mar 21, 2024 at 02:51:04AM +0000, Sudan Landge wrote: >>>> Virtual Machine Generation ID driver was introduced in commit af6b54e2b5ba >>>> ("virt: vmgenid: notify RNG of VM fork and supply generation ID"), as an >>>> ACPI only device. >>>> >>>> VMGenID specification http://go.microsoft.com/fwlink/?LinkId=260709 defines >>>> a mechanism for the BIOS/hypervisors to communicate to the virtual machine >>>> that it is executed with a different configuration (e.g. snapshot execution >>>> or creation from a template). >>>> The guest operating system can use the notification for various purposes >>>> such as re-initializing its random number generator etc. >>>> >>>> As per the specs, hypervisor should provide a globally unique identified, >>>> or GUID via ACPI. >>>> >>>> This patch tries to mimic the mechanism to provide the same functionality >>>> which is for a hypervisor/BIOS to notify the virtual machine when it is >>>> executed with a different configuration. >>>> >>>> As part of this support the devicetree bindings requires the hypervisors or >>>> BIOS to provide a memory address which holds the GUID and an IRQ which is >>>> used to notify when there is a change in the GUID. >>>> The memory exposed in the DT should follow the rules defined in the >>>> vmgenid spec mentioned above. >>>> >>>> *Reason for this change*: >>>> Chosing ACPI or devicetree is an intrinsic part of an hypervisor design. >>>> Without going into details of why a hypervisor would chose DT over ACPI, >>>> we would like to highlight that the hypervisors that have chose devicetree >>>> and now want to make use of the vmgenid functionality cannot do so today >>>> because vmgenid is an ACPI only device. >>>> This forces these hypervisors to change their design which could have >>>> undesirable impacts on their use-cases, test-scenarios etc. >>>> >>>> The point of vmgenid is to provide a mechanism to discover a GUID when >>>> the execution state of a virtual machine changes and the simplest >>>> way to do it is pass a memory location and an interrupt via devicetree. >>>> It would complicate things unnecessarily if instead of using devicetree, >>>> we try to implement a new protocol or modify other protocols to somehow >>>> provide the same functionility. >>>> >>>> We believe that adding a devicetree binding for vmgenid is a simpler, >>>> better alternative to provide the same functionality and will allow >>>> such hypervisors as mentioned above to continue using devicetree. >>>> >>>> More references to vmgenid specs: >>>> - https://www.qemu.org/docs/master/specs/vmgenid.html >>>> - https://learn.microsoft.com/en-us/windows/win32/hyperv_v2/virtual-machine-generation-identifier >>>> >>>> Signed-off-by: Sudan Landge >>>> --- >>>> .../devicetree/bindings/rng/vmgenid.yaml | 57 +++++++++++++++++++ >>>> MAINTAINERS | 1 + >>>> 2 files changed, 58 insertions(+) >>>> create mode 100644 Documentation/devicetree/bindings/rng/vmgenid.yaml >>>> >>>> diff --git a/Documentation/devicetree/bindings/rng/vmgenid.yaml b/Documentation/devicetree/bindings/rng/vmgenid.yaml >>>> new file mode 100644 >>>> index 000000000000..4b6ab62cc2ae >>>> --- /dev/null >>>> +++ b/Documentation/devicetree/bindings/rng/vmgenid.yaml >>>> @@ -0,0 +1,57 @@ >>>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) >>>> +%YAML 1.2 >>>> +--- >>>> +$id: http://devicetree.org/schemas/rng/vmgenid.yaml# >>>> +$schema: http://devicetree.org/meta-schemas/core.yaml# >>>> + >>>> +title: Virtual Machine Generation Counter ID device >>>> + >>>> +maintainers: >>>> + - Jason A. Donenfeld >>>> + >>>> +description: >>>> + Firmwares or hypervisors can use this devicetree to describe >>>> + interrupts and the shared resources to inject a Virtual Machine Generation >>>> + counter. >>>> + >>>> +properties: >>>> + compatible: >>>> + const: linux,vmgenctr >>> >>> Why 'linux'? It should be named for a particular host implementation >>> (and that implementation's bugs/quirks). However, this thing is simple >>> enough we can perhaps avoid that here. As the interface is defined by >>> Microsoft, then perhaps they should be the vendor here. >>> >> We chose "linux" because the current implementation and usage of >> devicetree was Linux specific. However, I think "virtual" would be a >> better choice than "Microsoft" since this is a generic virtual device >> that could be configured by any hypervisor or firmware not owned or >> related to Microsoft. I have updated this as part of the new version if >> it looks good. I don't have a strong opinion for "virtual" though so if >> that is the right choice as per you I can update it. > > I'm not really a fan of 'virtual' and its one and only existing use. > Don't add to it. > > Someone has defined how to read a GUID from register(s). I can think > of many ways that could be implemented. The data itself could be hex > or ascii. You could read N times from one register or read from N > sequential registers. And again, there's endianness and access sizes. > Given the only source of any of that is a Microsoft spec, then that > makes sense to me. Or just no vendor prefix is possible, but I prefer > to avoid those cases. ok, you are right. Using "Microsoft" as the compatible string makes more sense. I will use that. > > Also, consider 'vmgenctr' has basically 0 search results. 'vmgenid' > returns some relevant results. Not that search results are a > requirement for naming, but perhaps something to consider. > The original driver supports 2 ACPI CIDs, "VMGENCTR" and "VM_GEN_COUNTER" and as per this commit https://github.com/torvalds/linux/commit/0396e46dc46523cba8401a0df84f67cc0b6067ab "VMGENCTR" is to be used for VMGenID specs. So, I used "vmgenctr" to be consistent with its ACPI counterpart "VMGENCTR". >>>> + >>>> + "#interrupt-cells": >>>> + const: 3 >>>> + description: | >>>> + The 1st cell is the interrupt type. >>>> + The 2nd cell contains the interrupt number for the interrupt type. >>>> + The 3rd cell is for trigger type and level flags. >>>> + >>>> + interrupt-controller: true >>> >>> Why is this device an interrupt controller? >>> >> My devicetree references I took initially were incorrect which led to >> the addition of this, I have removed this in the next version. Sorry >> about that. > > Try again... > Ok, I will confirm my understanding and provide a better answer in my next mail. As you mentioned in another mail, I will also pause on posting any new version till the current threads are answered. >>>> + >>>> + reg: >>>> + description: | >>>> + specifies the base physical address and >>>> + size of the regions in memory which holds the VMGenID counter. >>> >>> Odd wrapping, but drop unless you have something specific to say about >>> region like perhaps the layout of the registers. Or maybe thats defined >>> somewhere else? >>> >>> Does the spec say anything about endianness or access size? DT assumes >>> native endianness by default. We have properties to deal these, but >>> would be better to be explicit if that's defined already. >>> >> The spec doesn't mention anything about the endianness but, I have >> updated the description with some more data. > > Then what does your driver assume? Microsoft may not have thought > about it because they don't care, but now you want to use DT so you > have to because it is frequently used on BE systems. If we define > something, then there's some hope. Otherwise, it's pretty much a > guarantee folks will do the opposite. > > Rob The driver does not assume any endianness. To provide more context, The hypervisor stores a 128bit unique ID at the address pointed by the "reg"'s 1st cell, driver memcpy's this ID to an internal context and uses memcmp to compare if the ID is new or old. But yes, it will be good to define a fixed endianness to avoid any error. I will update the description to use little endian.