Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2120738lqe; Tue, 9 Apr 2024 10:02:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUv3G8QMHIGpxZbKJSpwcnU3je6ydfz2cOY+N8YOvkoe5UgsmqUNgAqYAMc54f9sELssLsGv8bjlzTypuno9U2fdTGcHURU/rSkyaX9og== X-Google-Smtp-Source: AGHT+IGSa2tmbLMS0dMc94QsQes39P3eKaR2OaKcPP5QM3UXn4bBLAj870rnqqx8v3hGAkQjeLAR X-Received: by 2002:a05:6a21:609:b0:1a7:a4c1:7c7a with SMTP id ll9-20020a056a21060900b001a7a4c17c7amr445490pzb.32.1712682162901; Tue, 09 Apr 2024 10:02:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712682162; cv=pass; d=google.com; s=arc-20160816; b=peEM/vE7tHudlxTUN0yVoHl/IaFF5/tY8qpdGSs31VXrLpKT1gbl26TI/GOB8L79JZ diaaTyD9xJGgXsSL6hh8CwYdkRjc0pzX3ON9GAfgrBk7hMbAzlzz+o9D90nCXtLDctw6 L1Infe1XCA+HN7cg62tBTzk+j7C3vp8CY3Aw1nG2AfFuasBwcEJ8iXyeUVl/uhuOP3Xz GjLsn8iO8z3s+bHMLvzJO0cJPh6H2Aa/IZSzw6n4Lz4U0Vjda/DbENZtkhRKKd2wC4gj 4hbFR5iszK7z3oRb36/3y2i/5tk1qxbZYDYNmHyUQ4kKsyiKktI37nx07iHyJkcJ8Ug/ 9zsQ== 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=CpjtlYfYB815I3edko5hoKmeUv1NBBdqFoQm93IHRzCy0c4YSYUsZjcwHOPLy2ORmu AEHot2OuydWfJJlhB2JlX3xd+XbIkS7a1TCyudyFX1hX8eF7gg9fVv0HsO0MVycYSmnl GRTAbB5wc1bR3cuk9KYO4tmCDtD2dL9O1jxUcyEQVA30NQ08Yyt1gDXPWyeZqBdOeL5p sL3fGp50/a7ZgmU/JeZHi4usySa63ekj8iNySjcxmbH7mWyyqJC3DdPjYwfIltraJL9k GpeYorW/u+POHbmDSxA7McWCCP+WgzglEC53Ke6kQww1NwLg5TmeFRlakiM/XNqEqRI3 b2hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="JxmX/x9r"; 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-137354-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137354-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s2-20020a6550c2000000b005f07f354775si8937111pgp.660.2024.04.09.10.02.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 10:02:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137354-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="JxmX/x9r"; 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-137354-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137354-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8C2C0285795 for ; Tue, 9 Apr 2024 17:02:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9009155723; Tue, 9 Apr 2024 17:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="JxmX/x9r" Received: from smtp-fw-52005.amazon.com (smtp-fw-52005.amazon.com [52.119.213.156]) (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 2CFBC15383B; Tue, 9 Apr 2024 17:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.119.213.156 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712682126; cv=none; b=WnVM/IKva7hGLnTKIGnZ/93wObZrRyO7njNfzSdUeid/xkIjDA9e94O0XD98ir3m8Y8LOnGKAXVPIcHl/F5kKiO6owKjgyQBllVe7aZ97TIr1QYnRrpZIufQmvNzLjM+hdLkNoDAVzthxE83dj0dU8oY35CLvzJi7DQQ+GSQeck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712682126; c=relaxed/simple; bh=QkafSvTNtQW6+3b2nz2VphYjP8TdVziVHIwU42lTGFA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tw8sbWfKK+wAGBQ9LQW7hm3Poni0Br1zzu1ougBBIuUV1349wOtV1P3hXp6OWnfCh0Svoit5SmMI8Fj9+vNxe5oXUL/FMJwAsBbW2hVfWRFApOI+zhwrLmeIYiu8ZdbsFQ09yejXvTRNVQa9z1KyaSCWKwiCKCjdTrkMNrSURlQ= 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=JxmX/x9r; arc=none smtp.client-ip=52.119.213.156 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=1712682124; x=1744218124; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wRWEzqpiRSCXXr8eSFs9h45pzjeKz7V1Hyw7h+XDODc=; b=JxmX/x9ru/iMf1WBhdhcUmetJBLOleClwwdqLX37UeIU1STirnoB6Bnh aGxlJkPG90wOkYq/wg2H2sLQD3wbKyKv5o5Yx1Msj7A6n3jYuCRg2ZPmO gYcOFO3vVn1b+2hc/p+69rTCYQ20iCWyWzJNDBKiRCa8SQMpIoP0jDx+C w=; X-IronPort-AV: E=Sophos;i="6.07,190,1708387200"; d="scan'208";a="646642518" 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-52005.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2024 17:02:02 +0000 Received: from EX19MTAEUC001.ant.amazon.com [10.0.10.100:41541] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.32.183:2525] with esmtp (Farcaster) id b2ee14cd-79d4-4f3e-847a-141df7f66460; Tue, 9 Apr 2024 17:02:01 +0000 (UTC) X-Farcaster-Flow-ID: b2ee14cd-79d4-4f3e-847a-141df7f66460 Received: from EX19D036EUC002.ant.amazon.com (10.252.61.191) by EX19MTAEUC001.ant.amazon.com (10.252.51.155) 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 17:02:00 +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 17:01:55 +0000 From: Sudan Landge To: , , , , , , , , , , CC: , , , Subject: [PATCH v4 1/5] virt: vmgenid: rearrange code to make review easier Date: Tue, 9 Apr 2024 18:01:33 +0100 Message-ID: <20240409170137.79197-2-sudanl@amazon.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240409170137.79197-1-sudanl@amazon.com> References: <20240409170137.79197-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: EX19D044UWA001.ant.amazon.com (10.13.139.100) 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