Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp398683imn; Wed, 3 Aug 2022 08:33:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uZC48AIP6diMmgCAySb+UVdAWvacibXaMwBlyh+UdhP4ulUVGhoMUf0w8hdCYEPmtvF94k X-Received: by 2002:a17:907:971c:b0:72b:83d2:aa7a with SMTP id jg28-20020a170907971c00b0072b83d2aa7amr20561604ejc.633.1659540807092; Wed, 03 Aug 2022 08:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659540807; cv=none; d=google.com; s=arc-20160816; b=cz0nCJsNbCsMNthpLc/a/fOAU4oSz6o63E+4N58fYT6PXMkLD2XyY5/HxjFi03XeYd v0rpA6BQ12NtUfTLp9XWci19J3NGQdpY+UKv2utX+xwgUpUZ7ocoacaPzJd52ICRmjH9 rGcm00C/DOCZw58fb/bMk04akDdZuSlZIzkUTy5yBayPMy1vgZVuT3qpx34zd7ZzB4z6 4fQpcBgLh4KKOGGRbGJY/qvOSC7up/hxSnwugDrdRnhXUecIndogwuAVBVJh8tSjEcag OJTmCHM+QAmQo6YVF3MfIPQbkB4E8Au0esC5OKiBx7ESAAed8SLOt72vdXeG8buBVIGp GPvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Tbu2vI/tuQpJhdPLbiU7SzaNS+QVhrT4UaYznxDPAGo=; b=ddIePgiauI+gVrM2fwba4hWg0HN4uENqfXxv4jZ8KqxbLp1epQhdpEeiAO5AV+1KuE PUDAXzTKim3O5Nb/qafW1AacdsvTHRjScLJcXXOq4tVkg+VeK/FbYHSsHjPTy0pS1ZWi xwnIKqXbCvyNr+emmWafIC/L3AFZUAom6P66UH8JGBGcKoZAnjLyhftvmFslv4CX49ZC ABziKmVJS0f/1sBOgRGS4y5DHFxsz8DFa+G5vFFrbJ3Fc9NoJiqQDhMeW/nZS5Ox0v5X 14E2HY8AVl9wth6MaFmEP+pRBz9J1kRkKpf9Mmi4hQNjVo2q1YF5Ck8cx9jNYRziQtsw Z5gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.es header.s=amazon201209 header.b=PwiM9Mse; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.es Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020a170906974d00b007262ad8839esi17447674ejy.16.2022.08.03.08.33.01; Wed, 03 Aug 2022 08:33:27 -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=@amazon.es header.s=amazon201209 header.b=PwiM9Mse; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.es Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238001AbiHCPZK (ORCPT + 99 others); Wed, 3 Aug 2022 11:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233041AbiHCPZI (ORCPT ); Wed, 3 Aug 2022 11:25:08 -0400 Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4D825FDB for ; Wed, 3 Aug 2022 08:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.es; i=@amazon.es; q=dns/txt; s=amazon201209; t=1659540307; x=1691076307; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Tbu2vI/tuQpJhdPLbiU7SzaNS+QVhrT4UaYznxDPAGo=; b=PwiM9MseAso+d9qYizAKUqLkzNMJBd+ArBmzMTnX4w8r8lSzqCkyWzQe AtETtTXtohYTHIK8sRTgO9P5A+pLYcAKgsERe/QeDGG4xQ6oJPdxjJ4Bl EmV/bK/n0KbV9ldI6JC8B9eYNsIIyzLGCzDVFHI+DNJX2v0+5abJ1Raz/ M=; X-IronPort-AV: E=Sophos;i="5.93,214,1654560000"; d="scan'208";a="115297759" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-e6c05252.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 15:21:44 +0000 Received: from EX13D37EUA003.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2a-e6c05252.us-west-2.amazon.com (Postfix) with ESMTPS id C002143D01; Wed, 3 Aug 2022 15:21:42 +0000 (UTC) Received: from f4d4887fdcfb.ant.amazon.com (10.43.162.134) by EX13D37EUA003.ant.amazon.com (10.43.165.7) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Wed, 3 Aug 2022 15:21:37 +0000 From: To: CC: , , , , , , Subject: [PATCH 0/2] virt: vmgenid: add generation counter Date: Wed, 3 Aug 2022 17:21:25 +0200 Message-ID: <20220803152127.48281-1-bchalios@amazon.es> X-Mailer: git-send-email 2.32.1 (Apple Git-133) MIME-Version: 1.0 X-Originating-IP: [10.43.162.134] X-ClientProxiedBy: EX13D07UWB003.ant.amazon.com (10.43.161.66) To EX13D37EUA003.ant.amazon.com (10.43.165.7) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 From: Babis Chalios Linux recently added support for the VM Generation ID mechanism from Microsoft. The way this works currently is using the 128-bit blob provided by the vmgenid device to re-seed the RNG. While this works it has two main issues, (a) it is inherently racy due to the fact that it relies on a ACPI notification being delivered and handled and (b) the ID is unsuitable for exposing to user-space. This patch-set extends the vmgenid device to introduce a generation counter, a 32-bit counter which is different every time the unique ID changes. The addition to the original implementation in QEMU can be found here: https://lists.nongnu.org/archive/html/qemu-devel/2022-08/msg00524.html. The first patch re-works slightly the current vmgenid driver to add a function that parses an object from the vmgenid device and returns the physical address of the vmgenid data. The second patch uses that function to parse additionally the address of the generation counter from the vmgenid namespace. The counter is then exposed to the user-space through a misc-device which provides `read` and `mmap` interfaces. Babis Chalios (2): virt: vmgenid: add helper function to parse ADDR virt: vmgenid: add support for generation counter Documentation/virt/vmgenid.rst | 120 ++++++++++++++++++++++++++ drivers/virt/vmgenid.c | 151 ++++++++++++++++++++++++++++----- 2 files changed, 251 insertions(+), 20 deletions(-) create mode 100644 Documentation/virt/vmgenid.rst -- 2.37.1 Amazon Spain Services sociedad limitada unipersonal, Calle Ramirez de Prado 5, 28045 Madrid. Registro Mercantil de Madrid . Tomo 22458 . Folio 102 . Hoja M-401234 . CIF B84570936