Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2175449lqe; Tue, 9 Apr 2024 11:35:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdsKwVRBVr+CPTc8Frd39waAbab4uKJuZN+8RvI7OOnYEmovpnrvH3DDgkJ/H0lQikmCcaEr9MKZk1aLF2msBsonmGNJoFnG0Dt3XpIg== X-Google-Smtp-Source: AGHT+IFItPAJs8Q0q73i99gtfUB5UyBB/+z9x9Ww7C7OZVhcyP4MeMfZcZzp7hbobDoWBVkAI9yZ X-Received: by 2002:a05:6a20:9703:b0:1a8:2cc0:290a with SMTP id hr3-20020a056a20970300b001a82cc0290amr638241pzc.30.1712687735718; Tue, 09 Apr 2024 11:35:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712687735; cv=pass; d=google.com; s=arc-20160816; b=expyYvhTWwhcFipWu8IfYcPtyxkZ2zqYuJTqSh0kDqNZeKtOGF2ep9ktf0klxAi3// eUGfNe3gGZwOngifV/RcUcHyxJCGJbGKmBMAkNHq30rMVkmJyx0tHKKrWhxNuHaxLw+Z m766QY5TqyIfZx1fZP2mAZFK6x1eHwP1JQmQaKEBBwEdfBr3QP6+zvo+kROsuaty6a9q Ssj52zprm6zEkGHmyGceYjpaULm+RAW0QjGQEZAEfLjM97tNj3dfjNAmUz8YOJsbUEXz H6gyYYFm9R499H+ija6h6H9S5buAxXPJhlmSpifMqbwS9G1RPVd+sUl03CKJqseYCN8i pncQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wRWEzqpiRSCXXr8eSFs9h45pzjeKz7V1Hyw7h+XDODc=; fh=eulCrYuY4zK7Gxr6B+4yAHyThWGi9/x0Te9WMho9aNk=; b=Sg/vraYK9fGe7YFScWgRis8INDSXBvasduM2WEwMXitrlC052cjbcRoPhuTS3F+6Th gqL+CdNF/CA87ul9ousCKhVzB4IokrB2+m50lvbGkvbgT2eo6f+FxrVKaYvAZx7cC34o ulE/cZqvsse82TDFBEGyxWrrvsCH4pl1hCtvcO/5kC2xyTSoK/sVxK8wXS8c+vo9PgDD 00P1pcbTnYqlPHTmqC78dnH5Y5Nkp6ifg1qLvU1jkHLBY12AHlT0N5TdLXOyJ2qIO7dk P6aKvCBRPUXuCMlcw5fHTPMXWPxgmZ6yJ116a1J9MoVp1RlaUergenb4d92MhBM5+nzt 1BOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=vqm93Fco; arc=pass (i=1 spf=pass spfdomain=amazon.co.uk dkim=pass dkdomain=amazon.com dmarc=pass fromdomain=amazon.com); spf=pass (google.com: domain of linux-kernel+bounces-137460-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137460-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i12-20020aa787cc000000b006e69fdb9967si8904860pfo.3.2024.04.09.11.35.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 11:35:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137460-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=vqm93Fco; arc=pass (i=1 spf=pass spfdomain=amazon.co.uk dkim=pass dkdomain=amazon.com dmarc=pass fromdomain=amazon.com); spf=pass (google.com: domain of linux-kernel+bounces-137460-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137460-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E560DB23A6B for ; Tue, 9 Apr 2024 18:22:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 954AB156C6A; Tue, 9 Apr 2024 18:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="vqm93Fco" Received: from smtp-fw-52004.amazon.com (smtp-fw-52004.amazon.com [52.119.213.154]) (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 0CC5513C66C; Tue, 9 Apr 2024 18:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.119.213.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712686930; cv=none; b=Pyl1if8ASfsAXDeI8bnJxn49vbyJsKeEQRgQ3cDqLGApADwLthDjue4xNZCgayYW+F3qVrXPUAxYui1GAuW1CUqWjkatOU7layuOoNVu42qvzgfjraqxETG9c2+hX+l86yufCFdz+fUvXFUOe+sNQkxZw97qaLtgOzke4Dob68I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712686930; c=relaxed/simple; bh=QkafSvTNtQW6+3b2nz2VphYjP8TdVziVHIwU42lTGFA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fknXq315nUaoD9+XIr9W4HkOYj4wFftqcNkSLT78Z3+2/nyBt/nroGioDz5znsCTVfLVCXrz7jRQIqBdvLXsiV07+jXFGhyKsphzCVb8jmaCJAlZeT6qJzaDpfOhcSF/dZJhTiAMT43Oe8jcNbvqz6f/U1TR5IZK+ZuVz5LVC6s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.uk; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=vqm93Fco; arc=none smtp.client-ip=52.119.213.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com 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.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1712686929; x=1744222929; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wRWEzqpiRSCXXr8eSFs9h45pzjeKz7V1Hyw7h+XDODc=; b=vqm93FcocA4Kr1cJ9uIvQcFzrqedHG9AO98SPe8CqXTT+BqkeqK/6iSC akfMxV4hw9/uREvgWJrWOHDb/yQNS8YvHFwCbLrpMKso9gGX9i5tAceZk H7MjorYDvvQuz3JDhw2n8CvxrUNLQ3nUuKoMmIAcudXB6bBm1/EhDLahU 0=; X-IronPort-AV: E=Sophos;i="6.07,190,1708387200"; d="scan'208";a="197485156" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.2]) by smtp-border-fw-52004.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 18:12:41 +0000 Received: from EX19MTAEUA002.ant.amazon.com [10.0.10.100:10210] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.9.204:2525] with esmtp (Farcaster) id b7737256-4eaa-42cb-880c-4086fe57a52b; Tue, 9 Apr 2024 18:12:39 +0000 (UTC) X-Farcaster-Flow-ID: b7737256-4eaa-42cb-880c-4086fe57a52b Received: from EX19D036EUC002.ant.amazon.com (10.252.61.191) by EX19MTAEUA002.ant.amazon.com (10.252.50.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Tue, 9 Apr 2024 18:12:39 +0000 Received: from bcd074994f7f.amazon.com (10.95.97.144) 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, 9 Apr 2024 18:12:34 +0000 From: Sudan Landge To: , , , , , , , , , , CC: , , , Subject: [PATCH v4 1/5] virt: vmgenid: rearrange code to make review easier Date: Tue, 9 Apr 2024 19:11:50 +0100 Message-ID: <20240409181154.9962-2-sudanl@amazon.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240409181154.9962-1-sudanl@amazon.com> References: <20240409181154.9962-1-sudanl@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D031UWC003.ant.amazon.com (10.13.139.252) To EX19D036EUC002.ant.amazon.com (10.252.61.191) Rearrage the functions of vmgenid to make the next commit, which re-implements vmgenid as a platform driver, easier to review. Signed-off-by: Sudan Landge --- drivers/virt/vmgenid.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c index b67a28da4702..a167ccfad299 100644 --- a/drivers/virt/vmgenid.c +++ b/drivers/virt/vmgenid.c @@ -21,6 +21,20 @@ struct vmgenid_state { u8 this_id[VMGENID_SIZE]; }; +static void vmgenid_notify(struct acpi_device *device, u32 event) +{ + struct vmgenid_state *state = acpi_driver_data(device); + char *envp[] = { "NEW_VMGENID=1", NULL }; + u8 old_id[VMGENID_SIZE]; + + memcpy(old_id, state->this_id, sizeof(old_id)); + memcpy(state->this_id, state->next_id, sizeof(state->this_id)); + if (!memcmp(old_id, state->this_id, sizeof(old_id))) + return; + add_vmfork_randomness(state->this_id, sizeof(state->this_id)); + kobject_uevent_env(&device->dev.kobj, KOBJ_CHANGE, envp); +} + static int vmgenid_add(struct acpi_device *device) { struct acpi_buffer parsed = { ACPI_ALLOCATE_BUFFER }; @@ -65,25 +79,12 @@ static int vmgenid_add(struct acpi_device *device) return ret; } -static void vmgenid_notify(struct acpi_device *device, u32 event) -{ - struct vmgenid_state *state = acpi_driver_data(device); - char *envp[] = { "NEW_VMGENID=1", NULL }; - u8 old_id[VMGENID_SIZE]; - - memcpy(old_id, state->this_id, sizeof(old_id)); - memcpy(state->this_id, state->next_id, sizeof(state->this_id)); - if (!memcmp(old_id, state->this_id, sizeof(old_id))) - return; - add_vmfork_randomness(state->this_id, sizeof(state->this_id)); - kobject_uevent_env(&device->dev.kobj, KOBJ_CHANGE, envp); -} - static const struct acpi_device_id vmgenid_ids[] = { { "VMGENCTR", 0 }, { "VM_GEN_COUNTER", 0 }, { } }; +MODULE_DEVICE_TABLE(acpi, vmgenid_ids); static struct acpi_driver vmgenid_driver = { .name = "vmgenid", @@ -97,7 +98,6 @@ static struct acpi_driver vmgenid_driver = { module_acpi_driver(vmgenid_driver); -MODULE_DEVICE_TABLE(acpi, vmgenid_ids); MODULE_DESCRIPTION("Virtual Machine Generation ID"); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Jason A. Donenfeld "); -- 2.34.1