From nobody Sat Feb 7 15:02:42 2026 Received: from pdx-out-004.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-004.esa.us-west-2.outbound.mail-perimeter.amazon.com [44.246.77.92]) (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 7FEE737D11C; Fri, 30 Jan 2026 17:37:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=44.246.77.92 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794642; cv=none; b=dJACF3yOj6Vhpk2Jxg7aPW8glionnsn5gfj/pXgnR6DGlmAUtDSfQY5lcWCnirQLIhz29oZmK0ycL+GzdXZeZqacCS87rj0PEWVVgtfOHvIaHWGaoaognsrUQXoNp9wMSv+hZMcgjZt7vLl9apLOXX6ysN43lF91D+Z2AT4xi2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794642; c=relaxed/simple; bh=LA/JT24Y3WjoSTmwnPRQMbf92mtqC/hdHWEqgCNVRWI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sSydj4eNkFKJsiN7jdGY/pUF1jxColLKph7pEfO/KpQaHZ+Mz6vj4e/Mt0ksKyS/55AIA6Jq/uXpDIEMR3rkRDxIdjc7t/OeQVMpVCkCjQ35x+B5t4uU3YtbNNk38EaTdheALNjM9i+OkPrRzO1Ag2BLIgGh+7otxseNOIIo8eU= 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 (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=GAkgessB; arc=none smtp.client-ip=44.246.77.92 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="GAkgessB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1769794640; x=1801330640; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HJNJQ5JEVCdL0Nrz7O4LdClGsPLkSanD1Ydscs5SXNk=; b=GAkgessB3NEuS9Tfyl3Q+xhkx/ZiQbheopHrXh1/HOPrvh0ideSMoetk k/N8o0wsZHRXMUMnVm5Kp6rCtZsG66ajDba01ovk1XQZatYiycHQ64Gbu QeeQbHqA42CcYmEOz8dfLt02fPijdME0aU6ipRF0Jo8+1DjFFFwKBrkmk 7bWjBHMu3QV/+TWN7FEaUXVzzSKN7nGIopAetbTowkQZYHi7hoM9rQZIx W0gbRXbnkRdqS3c8f0aGftuK9zRA6DUsNCmnMmp21geGtiRiGrhgGIz0l RIY7jSm+lMbu+yvP36fA7pCLgE6Q89eoS1W2eD6LZ6A7SFc4uBDAufgOI g==; X-CSE-ConnectionGUID: bkJYHQ6XTsmB3iW2GSQ88Q== X-CSE-MsgGUID: 2vR+Sjq9R5ypDXY1bQKwXg== X-IronPort-AV: E=Sophos;i="6.21,263,1763424000"; d="scan'208";a="11933846" Received: from ip-10-5-0-115.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.0.115]) by internal-pdx-out-004.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 17:37:17 +0000 Received: from EX19MTAUWC001.ant.amazon.com [205.251.233.105:20150] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.53.147:2525] with esmtp (Farcaster) id 49fe7975-cc0b-423a-892a-9cc7c84502b6; Fri, 30 Jan 2026 17:37:17 +0000 (UTC) X-Farcaster-Flow-ID: 49fe7975-cc0b-423a-892a-9cc7c84502b6 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:17 +0000 Received: from dev-dsk-itazur-1b-11e7fc0f.eu-west-1.amazon.com (172.19.66.53) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:14 +0000 From: Takahiro Itazuri To: , , , , , , , CC: , , , Babis Chalios , "Alexander Graf" , , Marco Cali , David Woodhouse , "Takahiro Itazuri" Subject: [PATCH v7 1/7] ptp: vmclock: add vm generation counter Date: Fri, 30 Jan 2026 17:36:00 +0000 Message-ID: <20260130173704.12575-2-itazur@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260130173704.12575-1-itazur@amazon.com> References: <20260130173704.12575-1-itazur@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: quoted-printable X-ClientProxiedBy: EX19D033UWC002.ant.amazon.com (10.13.139.196) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="utf-8" From: Babis Chalios Similar to live migration, loading a VM from some saved state (aka snapshot) is also an event that calls for clock adjustments in the guest. However, guests might want to take more actions as a response to such events, e.g. as discarding UUIDs, resetting network connections, reseeding entropy pools, etc. These are actions that guests don't typically take during live migration, so add a new field in the vmclock_abi called vm_generation_counter which informs the guest about such events. Hypervisor advertises support for vm_generation_counter through the VMCLOCK_FLAG_VM_GEN_COUNTER_PRESENT flag. Users need to check the presence of this bit in vmclock_abi flags field before using this flag. Signed-off-by: Babis Chalios Signed-off-by: David Woodhouse Reviewed-by: David Woodhouse Tested-by: Takahiro Itazur --- include/uapi/linux/vmclock-abi.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/uapi/linux/vmclock-abi.h b/include/uapi/linux/vmclock-= abi.h index 2d99b29ac..937fe00e4 100644 --- a/include/uapi/linux/vmclock-abi.h +++ b/include/uapi/linux/vmclock-abi.h @@ -115,6 +115,12 @@ struct vmclock_abi { * bit again after the update, using the about-to-be-valid fields. */ #define VMCLOCK_FLAG_TIME_MONOTONIC (1 << 7) + /* + * If the VM_GEN_COUNTER_PRESENT flag is set, the hypervisor will + * bump the vm_generation_counter field every time the guest is + * loaded from some save state (restored from a snapshot). + */ +#define VMCLOCK_FLAG_VM_GEN_COUNTER_PRESENT (1 << 8) =20 __u8 pad[2]; __u8 clock_status; @@ -177,6 +183,15 @@ struct vmclock_abi { __le64 time_frac_sec; /* Units of 1/2^64 of a second */ __le64 time_esterror_nanosec; __le64 time_maxerror_nanosec; + + /* + * This field changes to another non-repeating value when the guest + * has been loaded from a snapshot. In addition to handling a + * disruption in time (which will also be signalled through the + * disruption_marker field), a guest may wish to discard UUIDs, + * reset network connections, reseed entropy, etc. + */ + __le64 vm_generation_counter; }; =20 #endif /* __VMCLOCK_ABI_H__ */ --=20 2.50.1 From nobody Sat Feb 7 15:02:42 2026 Received: from pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.34.181.151]) (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 1AD8D37D104; Fri, 30 Jan 2026 17:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.34.181.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794649; cv=none; b=K1WhR2cAaf75khtURzHKxdtCtnkJesXpkY5pXZyMtdQz3hscCftmjnROP88YzM58mgp8+xlB3JiL+Jj/oPcZrkSib+QT3bc/cOGnAbdxZRjUW8dvD7Sx9uwQbfwxC25urBMUg9M5aaW+ty8a2+d6lOeYE3no/w/lYunhRIquu7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794649; c=relaxed/simple; bh=qd7OuSMeyfx2vbahH2DvVR71ZMlZ2ZkNC6n9Ks9VfpY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Svs/360mcjrCSP3eWtYOsb4NGjQaRqkCFtgQmoMvB5J8bDPlugJhgSpDrQr8XS1glodmVJf9wwA8XWRpbIwTJTqTlGhZ3g9+gidKZHC6FdG0mcUVd4P0odrVNGYqRhBcadwqcNJbvwqGIEHpTJb4Zc7iNYB0DBLhSO3S/IEIwFU= 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 (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=myLIVi35; arc=none smtp.client-ip=52.34.181.151 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="myLIVi35" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1769794648; x=1801330648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pGq67HxLwPOMeoy7DWGTj0PKuwBUDlWYUTExVg0WhLg=; b=myLIVi35T9KEgDGVPFFfpIx3zNqMe0Mn3d11JNYLazKwAVrJzQu0blhj H1czErC7Yiav5VJckXqVQuJ2h9z4bmbDzxT7dTSN21VktowmL1WWnBapw DkGDvZT8zwqehTaG7ZsIdNGceV+AJOBPhBn2ojKPWCYi2TzFI/i7Ip2Lx /hXk0DcJKXRTDrCQ+cVZbJQHsv0I2sqvb6yI3K2hMv9bIiMmzJqHNr3ZH dmpILJim/0h9geGP51J3iAG0Q39O/22DLPY587fR4bl/uLJuzsx5jjCOS q6QNLyHoIlSP70XweCCVRtL9aFsEBXVhT5DebJ65lNXcehBvdJHbRB/SF w==; X-CSE-ConnectionGUID: A5f1qz+dQeeHrzL9NZoWnA== X-CSE-MsgGUID: 6/YGN6fgTTK1DK2N3OBbgg== X-IronPort-AV: E=Sophos;i="6.21,263,1763424000"; d="scan'208";a="11942245" Received: from ip-10-5-0-115.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.0.115]) by internal-pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 17:37:25 +0000 Received: from EX19MTAUWB002.ant.amazon.com [205.251.233.111:11861] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.0.123:2525] with esmtp (Farcaster) id 51784996-2e85-43ff-9784-38e16fd4490a; Fri, 30 Jan 2026 17:37:24 +0000 (UTC) X-Farcaster-Flow-ID: 51784996-2e85-43ff-9784-38e16fd4490a Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:24 +0000 Received: from dev-dsk-itazur-1b-11e7fc0f.eu-west-1.amazon.com (172.19.66.53) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:21 +0000 From: Takahiro Itazuri To: , , , , , , , CC: , , , Babis Chalios , "Alexander Graf" , , Marco Cali , David Woodhouse , "Takahiro Itazuri" Subject: [PATCH v7 2/7] ptp: vmclock: support device notifications Date: Fri, 30 Jan 2026 17:36:01 +0000 Message-ID: <20260130173704.12575-3-itazur@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260130173704.12575-1-itazur@amazon.com> References: <20260130173704.12575-1-itazur@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: EX19D031UWC004.ant.amazon.com (10.13.139.246) To EX19D001UWA001.ant.amazon.com (10.13.138.214) From: Babis Chalios Add optional support for device notifications in VMClock. When supported, the hypervisor will send a device notification every time it updates the seq_count to a new even value. Moreover, add support for poll() in VMClock as a means to propagate this notification to user space. poll() will return a POLLIN event to listeners every time seq_count changes to a value different than the one last seen (since open() or last read()/pread()). This means that when poll() returns a POLLIN event, listeners need to use read() to observe what has changed and update the reader's view of seq_count. In other words, after a poll() returned, all subsequent calls to poll() will immediately return with a POLLIN event until the listener calls read(). The device advertises support for the notification mechanism by setting flag VMCLOCK_FLAG_NOTIFICATION_PRESENT in vmclock_abi flags field. If the flag is not present the driver won't setup the ACPI notification handler and poll() will always immediately return POLLHUP. Signed-off-by: Babis Chalios Signed-off-by: David Woodhouse Signed-off-by: Takahiro Itazuri Reviewed-by: David Woodhouse Tested-by: Takahiro Itazuri --- drivers/ptp/ptp_vmclock.c | 162 +++++++++++++++++++++++++++---- include/uapi/linux/vmclock-abi.h | 5 + 2 files changed, 148 insertions(+), 19 deletions(-) diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c index b3a83b03d..f8b24f9e8 100644 --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -5,6 +5,9 @@ * Copyright =C2=A9 2024 Amazon.com, Inc. or its affiliates. */ =20 +#include "linux/poll.h" +#include "linux/types.h" +#include "linux/wait.h" #include #include #include @@ -39,6 +42,7 @@ struct vmclock_state { struct resource res; struct vmclock_abi *clk; struct miscdevice miscdev; + wait_queue_head_t disrupt_wait; struct ptp_clock_info ptp_clock_info; struct ptp_clock *ptp_clock; enum clocksource_ids cs_id, sys_cs_id; @@ -357,10 +361,15 @@ static struct ptp_clock *vmclock_ptp_register(struct = device *dev, return ptp_clock_register(&st->ptp_clock_info, dev); } =20 +struct vmclock_file_state { + struct vmclock_state *st; + atomic_t seq; +}; + static int vmclock_miscdev_mmap(struct file *fp, struct vm_area_struct *vm= a) { - struct vmclock_state *st =3D container_of(fp->private_data, - struct vmclock_state, miscdev); + struct vmclock_file_state *fst =3D fp->private_data; + struct vmclock_state *st =3D fst->st; =20 if ((vma->vm_flags & (VM_READ|VM_WRITE)) !=3D VM_READ) return -EROFS; @@ -379,11 +388,11 @@ static int vmclock_miscdev_mmap(struct file *fp, stru= ct vm_area_struct *vma) static ssize_t vmclock_miscdev_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos) { - struct vmclock_state *st =3D container_of(fp->private_data, - struct vmclock_state, miscdev); ktime_t deadline =3D ktime_add(ktime_get(), VMCLOCK_MAX_WAIT); + struct vmclock_file_state *fst =3D fp->private_data; + struct vmclock_state *st =3D fst->st; + uint32_t seq, old_seq; size_t max_count; - uint32_t seq; =20 if (*ppos >=3D PAGE_SIZE) return 0; @@ -392,6 +401,7 @@ static ssize_t vmclock_miscdev_read(struct file *fp, ch= ar __user *buf, if (count > max_count) count =3D max_count; =20 + old_seq =3D atomic_read(&fst->seq); while (1) { seq =3D le32_to_cpu(st->clk->seq_count) & ~1U; /* Pairs with hypervisor wmb */ @@ -402,8 +412,16 @@ static ssize_t vmclock_miscdev_read(struct file *fp, c= har __user *buf, =20 /* Pairs with hypervisor wmb */ virt_rmb(); - if (seq =3D=3D le32_to_cpu(st->clk->seq_count)) - break; + if (seq =3D=3D le32_to_cpu(st->clk->seq_count)) { + /* + * Either we updated fst->seq to seq (the latest version we observed) + * or someone else did (old_seq =3D=3D seq), so we can break. + */ + if (atomic_try_cmpxchg(&fst->seq, &old_seq, seq) || + old_seq =3D=3D seq) { + break; + } + } =20 if (ktime_after(ktime_get(), deadline)) return -ETIMEDOUT; @@ -413,25 +431,62 @@ static ssize_t vmclock_miscdev_read(struct file *fp, = char __user *buf, return count; } =20 +static __poll_t vmclock_miscdev_poll(struct file *fp, poll_table *wait) +{ + struct vmclock_file_state *fst =3D fp->private_data; + struct vmclock_state *st =3D fst->st; + uint32_t seq; + + /* + * Hypervisor will not send us any notifications, so fail immediately + * to avoid having caller sleeping for ever. + */ + if (!(le64_to_cpu(st->clk->flags) & VMCLOCK_FLAG_NOTIFICATION_PRESENT)) + return POLLHUP; + + poll_wait(fp, &st->disrupt_wait, wait); + + seq =3D le32_to_cpu(st->clk->seq_count); + if (atomic_read(&fst->seq) !=3D seq) + return POLLIN | POLLRDNORM; + + return 0; +} + +static int vmclock_miscdev_open(struct inode *inode, struct file *fp) +{ + struct vmclock_state *st =3D container_of(fp->private_data, + struct vmclock_state, miscdev); + struct vmclock_file_state *fst =3D kzalloc(sizeof(*fst), GFP_KERNEL); + + if (!fst) + return -ENOMEM; + + fst->st =3D st; + atomic_set(&fst->seq, 0); + + fp->private_data =3D fst; + + return 0; +} + +static int vmclock_miscdev_release(struct inode *inode, struct file *fp) +{ + kfree(fp->private_data); + return 0; +} + static const struct file_operations vmclock_miscdev_fops =3D { .owner =3D THIS_MODULE, + .open =3D vmclock_miscdev_open, + .release =3D vmclock_miscdev_release, .mmap =3D vmclock_miscdev_mmap, .read =3D vmclock_miscdev_read, + .poll =3D vmclock_miscdev_poll, }; =20 /* module operations */ =20 -static void vmclock_remove(void *data) -{ - struct vmclock_state *st =3D data; - - if (st->ptp_clock) - ptp_clock_unregister(st->ptp_clock); - - if (st->miscdev.minor !=3D MISC_DYNAMIC_MINOR) - misc_deregister(&st->miscdev); -} - static acpi_status vmclock_acpi_resources(struct acpi_resource *ares, void= *data) { struct vmclock_state *st =3D data; @@ -459,6 +514,44 @@ static acpi_status vmclock_acpi_resources(struct acpi_= resource *ares, void *data return AE_ERROR; } =20 +static void +vmclock_acpi_notification_handler(acpi_handle __always_unused handle, + u32 __always_unused event, void *dev) +{ + struct device *device =3D dev; + struct vmclock_state *st =3D device->driver_data; + + wake_up_interruptible(&st->disrupt_wait); +} + +static int vmclock_setup_notification(struct device *dev, struct vmclock_s= tate *st) +{ + struct acpi_device *adev =3D ACPI_COMPANION(dev); + acpi_status status; + + /* + * This should never happen as this function is only called when + * has_acpi_companion(dev) is true, but the logic is sufficiently + * complex that Coverity can't see the tautology. + */ + if (!adev) + return -ENODEV; + + /* The device does not support notifications. Nothing else to do */ + if (!(le64_to_cpu(st->clk->flags) & VMCLOCK_FLAG_NOTIFICATION_PRESENT)) + return 0; + + status =3D acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, + vmclock_acpi_notification_handler, + dev); + if (ACPI_FAILURE(status)) { + dev_err(dev, "failed to install notification handler"); + return -ENODEV; + } + + return 0; +} + static int vmclock_probe_acpi(struct device *dev, struct vmclock_state *st) { struct acpi_device *adev =3D ACPI_COMPANION(dev); @@ -482,6 +575,30 @@ static int vmclock_probe_acpi(struct device *dev, stru= ct vmclock_state *st) return 0; } =20 +static void vmclock_remove(void *data) +{ + struct device *dev =3D data; + struct vmclock_state *st =3D dev->driver_data; + + if (!st) { + dev_err(dev, "%s called with NULL driver_data", __func__); + return; + } + + if (has_acpi_companion(dev)) + acpi_remove_notify_handler(ACPI_COMPANION(dev)->handle, + ACPI_DEVICE_NOTIFY, + vmclock_acpi_notification_handler); + + if (st->ptp_clock) + ptp_clock_unregister(st->ptp_clock); + + if (st->miscdev.minor !=3D MISC_DYNAMIC_MINOR) + misc_deregister(&st->miscdev); + + dev->driver_data =3D NULL; +} + static void vmclock_put_idx(void *data) { struct vmclock_state *st =3D data; @@ -545,7 +662,14 @@ static int vmclock_probe(struct platform_device *pdev) =20 st->miscdev.minor =3D MISC_DYNAMIC_MINOR; =20 - ret =3D devm_add_action_or_reset(&pdev->dev, vmclock_remove, st); + init_waitqueue_head(&st->disrupt_wait); + dev->driver_data =3D st; + + ret =3D devm_add_action_or_reset(&pdev->dev, vmclock_remove, dev); + if (ret) + return ret; + + ret =3D vmclock_setup_notification(dev, st); if (ret) return ret; =20 diff --git a/include/uapi/linux/vmclock-abi.h b/include/uapi/linux/vmclock-= abi.h index 937fe00e4..d320623b0 100644 --- a/include/uapi/linux/vmclock-abi.h +++ b/include/uapi/linux/vmclock-abi.h @@ -121,6 +121,11 @@ struct vmclock_abi { * loaded from some save state (restored from a snapshot). */ #define VMCLOCK_FLAG_VM_GEN_COUNTER_PRESENT (1 << 8) + /* + * If the NOTIFICATION_PRESENT flag is set, the hypervisor will send + * a notification every time it updates seq_count to a new even number. + */ +#define VMCLOCK_FLAG_NOTIFICATION_PRESENT (1 << 9) =20 __u8 pad[2]; __u8 clock_status; --=20 2.50.1 From nobody Sat Feb 7 15:02:42 2026 Received: from pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.26.1.71]) (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 C4A9737F72F; Fri, 30 Jan 2026 17:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.26.1.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794653; cv=none; b=c8DSWIturC7cXbd4nlFAI85fbew4IsPYFTAPs5dG7+eeL6JScn0jeF+ewgYvWAtJRRJKcvDmAn4Dac2vDQCrUyA7Fbtqt98Pm1E62iuGV9I47eKn9R/YzSgaknkdwtWkbOp0Gv4Ap/nM0IdpKhd5rZEDqWXTCMhxWuT4xQ8jeJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794653; c=relaxed/simple; bh=9Cm5DNZkq/Hgwzh/+IlRF0qOER2Rk8tXyZwzLLKv5+A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JJgIQIQKyTVZ9EaiIX3Io10UqGJYqjKeZQi20YtUmsfneM+9vSQhBxH9fBXfajM29H4MAEh4OvhTJRyjPvKW45EaoUUwXNWNn1ZBa4f/CLPKqlvSZOZGt0/VAwU6247O0QRHM2kA4ewS63jFEGe6i+iHkQM6BKVz+cqZOLeGzO0= 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 (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=MIDdEcBo; arc=none smtp.client-ip=52.26.1.71 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="MIDdEcBo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1769794651; x=1801330651; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PQNMcCbACGtxtiD5RQHIFZIrQp3M1GtcZTN/Ac/UvXg=; b=MIDdEcBo6jdJT76e3QsiYdBDHObhsVdNcF8U2XslAyb3OYTpPM7smK7t JFPlvEUMR2odKKaMEN1VrganVtIrLBHbqZ+UaA2RJXo+RZtcRVLHGyjSl KkAzwBNy/2xuEYbAAAcAlvOPuWN2Vdo3+5eqMZuyUcmc9+CvZuQvSVd0Q 6tAfUavFz46lUERwQrq7IHCK+gabQRRsfwtjq+/ADWO3s12h7YfA1sBWy p/2M3Gu4XRzdNh4hClOTGyQlZ9zt5G4TmdHmabg5Y9pKxn+76ipZQFwl1 PC9YuMvi3p2RB3s4ADh4bUHnl97toeEXUuzcabZ0d4ONpytl2qk1bS8TN w==; X-CSE-ConnectionGUID: pJbuojeBSc2hceduTda92Q== X-CSE-MsgGUID: Tu16s7ifSwumyFqID0J4Hg== X-IronPort-AV: E=Sophos;i="6.21,263,1763424000"; d="scan'208";a="11938887" Received: from ip-10-5-9-48.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.9.48]) by internal-pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 17:37:31 +0000 Received: from EX19MTAUWA002.ant.amazon.com [205.251.233.234:26086] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.0.174:2525] with esmtp (Farcaster) id 938ed664-37c9-4d78-8796-a787e8c1e99a; Fri, 30 Jan 2026 17:37:31 +0000 (UTC) X-Farcaster-Flow-ID: 938ed664-37c9-4d78-8796-a787e8c1e99a Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA002.ant.amazon.com (10.250.64.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:30 +0000 Received: from dev-dsk-itazur-1b-11e7fc0f.eu-west-1.amazon.com (172.19.66.53) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:27 +0000 From: Takahiro Itazuri To: , , , , , , , CC: , , , Babis Chalios , "Alexander Graf" , , Marco Cali , David Woodhouse , "Takahiro Itazuri" Subject: [PATCH v7 3/7] dt-bindings: ptp: Add amazon,vmclock Date: Fri, 30 Jan 2026 17:36:02 +0000 Message-ID: <20260130173704.12575-4-itazur@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260130173704.12575-1-itazur@amazon.com> References: <20260130173704.12575-1-itazur@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: quoted-printable X-ClientProxiedBy: EX19D042UWA002.ant.amazon.com (10.13.139.17) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="utf-8" From: David Woodhouse The vmclock device provides a PTP clock source and precise timekeeping across live migration and snapshot/restore operations. The binding has a required memory region containing the vmclock_abi structure and an optional interrupt for clock disruption notifications. The full spec is at https://uapi-group.org/specifications/specs/vmclock/ Signed-off-by: David Woodhouse Signed-off-by: Babis Chalios Reviewed-by: Krzysztof Kozlowski Tested-by: Takahiro Itazuri --- .../bindings/ptp/amazon,vmclock.yaml | 46 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/ptp/amazon,vmclock.ya= ml diff --git a/Documentation/devicetree/bindings/ptp/amazon,vmclock.yaml b/Do= cumentation/devicetree/bindings/ptp/amazon,vmclock.yaml new file mode 100644 index 000000000..357790df8 --- /dev/null +++ b/Documentation/devicetree/bindings/ptp/amazon,vmclock.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ptp/amazon,vmclock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Virtual Machine Clock + +maintainers: + - David Woodhouse + +description: + The vmclock device provides a precise clock source and allows for + accurate timekeeping across live migration and snapshot/restore + operations. The full specification of the shared data structure is + available at https://uapi-group.org/specifications/specs/vmclock/ + +properties: + compatible: + const: amazon,vmclock + + reg: + description: + Specifies the shared memory region containing the vmclock_abi struct= ure. + maxItems: 1 + + interrupts: + description: + Interrupt used to notify when the contents of the vmclock_abi struct= ure + have been updated. + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + ptp@80000000 { + compatible =3D "amazon,vmclock"; + reg =3D <0x80000000 0x1000>; + interrupts =3D ; + }; diff --git a/MAINTAINERS b/MAINTAINERS index e8f06145f..171813ea7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20728,6 +20728,7 @@ PTP VMCLOCK SUPPORT M: David Woodhouse L: netdev@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/ptp/amazon,vmclock.yaml F: drivers/ptp/ptp_vmclock.c F: include/uapi/linux/vmclock-abi.h =20 --=20 2.50.1 From nobody Sat Feb 7 15:02:42 2026 Received: from pdx-out-011.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-011.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.35.192.45]) (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 8B8B237F0F3; Fri, 30 Jan 2026 17:37:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.35.192.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794662; cv=none; b=P5FwwbC8DyszkHygYJx1mPTy3a0j8W6zg9EulbSKfQc8Ep8vJRNRoG9VWVhg7+nZYp656S0CuRkEWUUFgBeQmrsOj7QcxL7DtbPi+5BgTzmcFmXUJB8/6pO2+gJPyPnoOX3J3S1fYH2CF5kfjv4D5V7XZPGr1RjL2/+gI9OGSCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794662; c=relaxed/simple; bh=smOrr7rJtqJ1A/iQT/v59C5+7ftMjhEeBSqGWew1gNo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PZ4rStwQi/5Uxal/zwCgUeLjLvEu2n0LOlmimsCk5q6JjTnHnYihsAdTodkM3TuXEORreMn/K6z34Nll+ZI/zhAwguHjxlN1OHdEAQ6qDvMAHOOkmTeC1jZRsKmOvGBERFvxoVq0Ku0g8Xo5Gvp/kPqmqfiX9Uqc/++h/cLK7QI= 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 (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=F4T32OAn; arc=none smtp.client-ip=52.35.192.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="F4T32OAn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1769794660; x=1801330660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FgHEkCKDX6peL0Q9VZpqqddTmjBFrZxzV6jF7iiGbxI=; b=F4T32OAnGcW2EvMRwD5/jHYPs7lJjxp7iAUDa81EcVUBETbrrx8DGyIg eWuNif7+uHKze4pGQ6ZUaC6Tt8/5tMPs6ndSRttPXQ57ACZ4+3ZaaqREZ 3tZPnp2wwbkFIXc/pgwys4+wivN7i1d34r7i8KV3L5dq5I16Nf9WSlDrf h47nPLwbH1G3ANii7GFuHs1nbcpSc8GkMGwXVDUazK+vowpyZ3YiZsdSV sm6/ervbPRZxU7UGvha0PKwI1vhKBW55gaCY164Ifga1Sz07sdO+vaK2p tFY72/Tn/Z6gHguz66wos3ZYw2B9SjM2aEP0ganPgMVcM98gn4p7kMDTu A==; X-CSE-ConnectionGUID: A2t4NE0ETXiyhNRzB0iUlw== X-CSE-MsgGUID: aHBSknfIQya7DDbknB6mnQ== X-IronPort-AV: E=Sophos;i="6.21,263,1763424000"; d="scan'208";a="11720956" Received: from ip-10-5-12-219.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-011.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 17:37:37 +0000 Received: from EX19MTAUWB001.ant.amazon.com [205.251.233.104:21098] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.16.224:2525] with esmtp (Farcaster) id edd01702-61c8-47d5-ac65-d1bd6e6f9b19; Fri, 30 Jan 2026 17:37:37 +0000 (UTC) X-Farcaster-Flow-ID: edd01702-61c8-47d5-ac65-d1bd6e6f9b19 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:37 +0000 Received: from dev-dsk-itazur-1b-11e7fc0f.eu-west-1.amazon.com (172.19.66.53) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:34 +0000 From: Takahiro Itazuri To: , , , , , , , CC: , , , Babis Chalios , "Alexander Graf" , , Marco Cali , David Woodhouse , "Takahiro Itazuri" Subject: [PATCH v7 4/7] ptp: ptp_vmclock: Add device tree support Date: Fri, 30 Jan 2026 17:36:03 +0000 Message-ID: <20260130173704.12575-5-itazur@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260130173704.12575-1-itazur@amazon.com> References: <20260130173704.12575-1-itazur@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: quoted-printable X-ClientProxiedBy: EX19D046UWB004.ant.amazon.com (10.13.139.164) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="utf-8" From: David Woodhouse Add device tree support to the ptp_vmclock driver, allowing it to probe via device tree in addition to ACPI. Handle optional interrupt for clock disruption notifications, mirroring the ACPI notification behaviour. Although the interrupt is marked as 'optional' in the DT bindings, if the device *advertises* the VMCLOCK_FLAG_NOTIFICATION_ABSENT then it *should* have an interrupt. The driver will refuse to initialize if not. Signed-off-by: David Woodhouse Signed-off-by: Babis Chalios Signed-off-by: Takahiro Itazuri Tested-by: Takahiro Itazuri --- drivers/ptp/ptp_vmclock.c | 67 +++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c index f8b24f9e8..619c8e5a9 100644 --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -14,10 +14,13 @@ #include #include #include +#include +#include #include #include #include #include +#include #include #include =20 @@ -524,7 +527,7 @@ vmclock_acpi_notification_handler(acpi_handle __always_= unused handle, wake_up_interruptible(&st->disrupt_wait); } =20 -static int vmclock_setup_notification(struct device *dev, struct vmclock_s= tate *st) +static int vmclock_setup_acpi_notification(struct device *dev) { struct acpi_device *adev =3D ACPI_COMPANION(dev); acpi_status status; @@ -537,10 +540,6 @@ static int vmclock_setup_notification(struct device *d= ev, struct vmclock_state * if (!adev) return -ENODEV; =20 - /* The device does not support notifications. Nothing else to do */ - if (!(le64_to_cpu(st->clk->flags) & VMCLOCK_FLAG_NOTIFICATION_PRESENT)) - return 0; - status =3D acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, vmclock_acpi_notification_handler, dev); @@ -575,6 +574,55 @@ static int vmclock_probe_acpi(struct device *dev, stru= ct vmclock_state *st) return 0; } =20 +static irqreturn_t vmclock_of_irq_handler(int __always_unused irq, void *_= st) +{ + struct vmclock_state *st =3D _st; + + wake_up_interruptible(&st->disrupt_wait); + return IRQ_HANDLED; +} + +static int vmclock_probe_dt(struct device *dev, struct vmclock_state *st) +{ + struct platform_device *pdev =3D to_platform_device(dev); + struct resource *res; + + res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + + st->res =3D *res; + + return 0; +} + +static int vmclock_setup_of_notification(struct device *dev) +{ + struct platform_device *pdev =3D to_platform_device(dev); + int irq; + + irq =3D platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + return devm_request_irq(dev, irq, vmclock_of_irq_handler, IRQF_SHARED, + "vmclock", dev->driver_data); +} + +static int vmclock_setup_notification(struct device *dev, + struct vmclock_state *st) +{ + /* The device does not support notifications. Nothing else to do */ + if (!(le64_to_cpu(st->clk->flags) & VMCLOCK_FLAG_NOTIFICATION_PRESENT)) + return 0; + + if (has_acpi_companion(dev)) { + return vmclock_setup_acpi_notification(dev); + } else { + return vmclock_setup_of_notification(dev); + } +} + static void vmclock_remove(void *data) { struct device *dev =3D data; @@ -619,7 +667,7 @@ static int vmclock_probe(struct platform_device *pdev) if (has_acpi_companion(dev)) ret =3D vmclock_probe_acpi(dev, st); else - ret =3D -EINVAL; /* Only ACPI for now */ + ret =3D vmclock_probe_dt(dev, st); =20 if (ret) { dev_info(dev, "Failed to obtain physical address: %d\n", ret); @@ -719,11 +767,18 @@ static const struct acpi_device_id vmclock_acpi_ids[]= =3D { }; MODULE_DEVICE_TABLE(acpi, vmclock_acpi_ids); =20 +static const struct of_device_id vmclock_of_ids[] =3D { + { .compatible =3D "amazon,vmclock", }, + { }, +}; +MODULE_DEVICE_TABLE(of, vmclock_of_ids); + static struct platform_driver vmclock_platform_driver =3D { .probe =3D vmclock_probe, .driver =3D { .name =3D "vmclock", .acpi_match_table =3D vmclock_acpi_ids, + .of_match_table =3D vmclock_of_ids, }, }; =20 --=20 2.50.1 From nobody Sat Feb 7 15:02:42 2026 Received: from pdx-out-010.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-010.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.12.53.23]) (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 B22F437D11D; Fri, 30 Jan 2026 17:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.12.53.23 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794669; cv=none; b=F3VGZ6RlKegbUqHSyC4efTZVpfHWwkiSKxjcawZwGa3ngZcj56h/1AWOla9LlctGFAH12buCX3kqH0X0Mpg4GNZR90s180IhCmf2QzNpSmeXY3NnZR8ma1+7HmCQc1Jqxj6nPETmuaYlOQG4ANPjSL9JpDWdT3DE928CijrYlcU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794669; c=relaxed/simple; bh=APd8pzB5cGdSC+pgQ/q+8mHi7+R97VBwnJXA2a1YMJ4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h3qp/JqxKM3NIP0uSosinw45jo8tavf5r615fSPnezB/u4A6v1o5aycS5IKlEkcqOp8nAwntzGReeb1ahuJfjRHLWJ1toBAiV8379QG/E7uCAnZ7nuFD+eSvbfyV0WpRQ88sM+DWZTUHbx8bbCS/PtNJO9G/kbF+r0bsP93zS70= 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 (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=iDZV2BOm; arc=none smtp.client-ip=52.12.53.23 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="iDZV2BOm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1769794667; x=1801330667; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j7/ky8lgzP8J1iGcrsTGKcQFpgFnFWEGcw/I+sapgZc=; b=iDZV2BOmj5+Gtq4ES7BdG8HzVfEur0zxnrSGmAadj8DYwTogV0I5U8mR pn4zKidWnTD2k9L4brhgCkoTYXX2s9/CR0ET61z9wDEZwTkeVLEABRVgC aGCxcJlnx/yZVHj2iMbYm07b6gjc4iFpdOB30Sw+bPezD9uyJ319xOoAa l59rNIVfEpY/y0vpHo12QMVadjstPLLFLQsVVPbVObzj+a7tFJiblGDBc 3nj0a4bqcFEYWdZ1Wb5sdY3xEWvQD6AbPX2seJIO3d84QOJ1+pM4tg4mN Id1tBjad9bOF6btZCQ5jFn7GSwfZ8Mi03masMBSZPCZZ81EquVdmRA7TS A==; X-CSE-ConnectionGUID: Qu+AwT3DR+CxUosSuivkHw== X-CSE-MsgGUID: oORUnnsFQPqWXyuVEIP2MA== X-IronPort-AV: E=Sophos;i="6.21,263,1763424000"; d="scan'208";a="11815388" Received: from ip-10-5-0-115.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.0.115]) by internal-pdx-out-010.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 17:37:44 +0000 Received: from EX19MTAUWC002.ant.amazon.com [205.251.233.51:19909] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.0.174:2525] with esmtp (Farcaster) id a0a18a15-5f0a-4181-95d8-6977bcce1a0f; Fri, 30 Jan 2026 17:37:44 +0000 (UTC) X-Farcaster-Flow-ID: a0a18a15-5f0a-4181-95d8-6977bcce1a0f Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWC002.ant.amazon.com (10.250.64.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:43 +0000 Received: from dev-dsk-itazur-1b-11e7fc0f.eu-west-1.amazon.com (172.19.66.53) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:40 +0000 From: Takahiro Itazuri To: , , , , , , , CC: , , , Babis Chalios , "Alexander Graf" , , Marco Cali , David Woodhouse , "Takahiro Itazuri" Subject: [PATCH v7 5/7] ptp: ptp_vmclock: add 'VMCLOCK' to ACPI device match Date: Fri, 30 Jan 2026 17:36:04 +0000 Message-ID: <20260130173704.12575-6-itazur@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260130173704.12575-1-itazur@amazon.com> References: <20260130173704.12575-1-itazur@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: quoted-printable X-ClientProxiedBy: EX19D031UWA004.ant.amazon.com (10.13.139.19) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="utf-8" From: David Woodhouse As we finalised the spec, we spotted that vmgenid actually says that the _HID is supposed to be hypervisor-specific. Although in the 13 years since the original vmgenid doc was published, nobody seems to have cared about using _HID to distinguish between implementations on different hypervisors, and we only ever use the _CID. For consistency, match the _CID of "VMCLOCK" too. Signed-off-by: David Woodhouse Signed-off-by: Babis Chalios Tested-by: Takahiro Itazuri --- drivers/ptp/ptp_vmclock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c index 619c8e5a9..2a173bd28 100644 --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -763,6 +763,7 @@ static int vmclock_probe(struct platform_device *pdev) =20 static const struct acpi_device_id vmclock_acpi_ids[] =3D { { "AMZNC10C", 0 }, + { "VMCLOCK", 0 }, {} }; MODULE_DEVICE_TABLE(acpi, vmclock_acpi_ids); --=20 2.50.1 From nobody Sat Feb 7 15:02:42 2026 Received: from pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.26.1.71]) (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 CE59137D11D; Fri, 30 Jan 2026 17:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.26.1.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794674; cv=none; b=NhOQSHb9Ie4DcPOoZ5IbdSNCz4xEH6tS8KnzWSm8/sJJQIqasK39d6+rk7oltZZ1UdOi+zp4iryAA9OldxQEJpOvw8yFss2Kfh0wmG3aPgy7myyQKMwFOK1vEZioEEXfUhPFNbnKlLMe2OxSMy0hrN1U0VDjAE1LtA56rDq4vqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794674; c=relaxed/simple; bh=eKrGQqZndJmbrN53FpEmbmtFGaPkTxWIUsyQnfI9a2Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ue2sYrLxn9me9qHf2a1Miq54ylQ1hlYG7X1umlSAZvOrhResXLLpgupwEUfG7EjRfNO8Jk+HKAxk49+U48/iy35kf10ERubt0RbmA5sfpglNzGk2J/DEFlmM9ILjX4yWwJxkw6jiMXTY3VH6GNV5vcXuuO7wfDtImvUMJPjGcP8= 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 (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=jjrA99IT; arc=none smtp.client-ip=52.26.1.71 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="jjrA99IT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1769794672; x=1801330672; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ldAsiYfE+Zft1YuwKt94MhHJ/sfiO6sqo+h4iUvVj1s=; b=jjrA99ITKGYj/5tf89tp+oXOKK8Mc1hcnFcHKMZhC9Ybpws7QgoFELmx Q+Pj3lpSVv6qKumFiUIPbAQl8IZEEUzTa62Gu/zVIy28GZ+gL1tzVt84i NMRK1/f8HEnyQwGniKKSa25gb3TU/6bGOYtQE2XVuHj8pXAsuTupjhJeG AATBehxseSXOqlk8BbMdZQO8ebh5ALzjJYGwVqjEambBgkh06a6+JkUA7 bx1FHJne2UBQlQc9U3MYDcNaA0WjdT6g1i/iVG13Y1fe4F6KjylnLJN/F O1ibLamJxmkUOPUyYK3CO2qRaU0X/68QULv08nng4eSm/KRlrX5bG3CCe w==; X-CSE-ConnectionGUID: 7vK6jhG3QAydF2XPuesCIA== X-CSE-MsgGUID: 98aam8x6R3Sk+Yxy6ds3sQ== X-IronPort-AV: E=Sophos;i="6.21,263,1763424000"; d="scan'208";a="11938904" Received: from ip-10-5-12-219.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-006.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 17:37:52 +0000 Received: from EX19MTAUWA001.ant.amazon.com [205.251.233.236:9356] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.0.174:2525] with esmtp (Farcaster) id 8a299df5-e528-45d4-9fe7-56531cccbba8; Fri, 30 Jan 2026 17:37:52 +0000 (UTC) X-Farcaster-Flow-ID: 8a299df5-e528-45d4-9fe7-56531cccbba8 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA001.ant.amazon.com (10.250.64.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:50 +0000 Received: from dev-dsk-itazur-1b-11e7fc0f.eu-west-1.amazon.com (172.19.66.53) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:47 +0000 From: Takahiro Itazuri To: , , , , , , , CC: , , , Babis Chalios , "Alexander Graf" , , Marco Cali , David Woodhouse , "Takahiro Itazuri" Subject: [PATCH v7 6/7] ptp: ptp_vmclock: remove dependency on CONFIG_ACPI Date: Fri, 30 Jan 2026 17:36:05 +0000 Message-ID: <20260130173704.12575-7-itazur@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260130173704.12575-1-itazur@amazon.com> References: <20260130173704.12575-1-itazur@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: quoted-printable X-ClientProxiedBy: EX19D041UWA001.ant.amazon.com (10.13.139.124) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="utf-8" From: David Woodhouse Now that we added device tree support we can remove dependency on CONFIG_ACPI. Signed-off-by: David Woodhouse Signed-off-by: Babis Chalios Tested-by: Takahiro Itazuri --- drivers/ptp/Kconfig | 2 +- drivers/ptp/ptp_vmclock.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig index 5f8ea34d1..b93640ca0 100644 --- a/drivers/ptp/Kconfig +++ b/drivers/ptp/Kconfig @@ -134,7 +134,7 @@ config PTP_1588_CLOCK_KVM config PTP_1588_CLOCK_VMCLOCK tristate "Virtual machine PTP clock" depends on X86_TSC || ARM_ARCH_TIMER - depends on PTP_1588_CLOCK && ACPI && ARCH_SUPPORTS_INT128 + depends on PTP_1588_CLOCK && ARCH_SUPPORTS_INT128 default PTP_1588_CLOCK_KVM help This driver adds support for using a virtual precision clock diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c index 2a173bd28..b6e9d4c96 100644 --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -490,6 +490,7 @@ static const struct file_operations vmclock_miscdev_fop= s =3D { =20 /* module operations */ =20 +#if IS_ENABLED(CONFIG_ACPI) static acpi_status vmclock_acpi_resources(struct acpi_resource *ares, void= *data) { struct vmclock_state *st =3D data; @@ -573,6 +574,7 @@ static int vmclock_probe_acpi(struct device *dev, struc= t vmclock_state *st) =20 return 0; } +#endif /* CONFIG_ACPI */ =20 static irqreturn_t vmclock_of_irq_handler(int __always_unused irq, void *_= st) { @@ -616,11 +618,11 @@ static int vmclock_setup_notification(struct device *= dev, if (!(le64_to_cpu(st->clk->flags) & VMCLOCK_FLAG_NOTIFICATION_PRESENT)) return 0; =20 - if (has_acpi_companion(dev)) { +#if IS_ENABLED(CONFIG_ACPI) + if (has_acpi_companion(dev)) return vmclock_setup_acpi_notification(dev); - } else { - return vmclock_setup_of_notification(dev); - } +#endif + return vmclock_setup_of_notification(dev); } =20 static void vmclock_remove(void *data) @@ -633,10 +635,12 @@ static void vmclock_remove(void *data) return; } =20 +#if IS_ENABLED(CONFIG_ACPI) if (has_acpi_companion(dev)) acpi_remove_notify_handler(ACPI_COMPANION(dev)->handle, ACPI_DEVICE_NOTIFY, vmclock_acpi_notification_handler); +#endif =20 if (st->ptp_clock) ptp_clock_unregister(st->ptp_clock); @@ -664,9 +668,11 @@ static int vmclock_probe(struct platform_device *pdev) if (!st) return -ENOMEM; =20 +#if IS_ENABLED(CONFIG_ACPI) if (has_acpi_companion(dev)) ret =3D vmclock_probe_acpi(dev, st); else +#endif ret =3D vmclock_probe_dt(dev, st); =20 if (ret) { --=20 2.50.1 From nobody Sat Feb 7 15:02:42 2026 Received: from pdx-out-012.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-012.esa.us-west-2.outbound.mail-perimeter.amazon.com [35.162.73.231]) (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 491FA371040; Fri, 30 Jan 2026 17:38:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.162.73.231 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794681; cv=none; b=j944EARS7Hv+oUHRvQaRZPpR+RIWhsx+N34jtLew/b7nZW3iBjWYVnVMSP+eifcz6VRQ0mgKeHgjwrEfuVlAR+ban9PLHI9sVbJJRz+WveWDt0C6tiUWC8dJN+q4iIul5JiCqx4/97kM08ZlBw3B/faOBcuMKzNjeHCZJdPicmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769794681; c=relaxed/simple; bh=HtAlXAZcolOufqDMf/VXwn7/loLBn96spGHI3kdbqm4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bS9EQPNCPm/WVifR8cu0qkJrJN/ohEUF39sFQsTiUD65NI0p7u04P9Fq1/FPxiU55Ex8CJQ1b9ICsYo9KY7DVuPlEK0XG3YZa7uahSbcWipnAB7ewl+VlTReAcPs6VjbN+jIyPq0bucSXpKYmbChYdBO3zP80buIdfb+G6cDVgg= 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 (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=PaKRi/kd; arc=none smtp.client-ip=35.162.73.231 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="PaKRi/kd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1769794680; x=1801330680; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vpLeB0JvZrWGa5+/2pZgLiAZzuec5SAaVzWSTRXFViA=; b=PaKRi/kdRe4mlaDX1EAQo2UqGlHVrZYVBUXsDh31dPDMJAwv55N4Up/N pKF3CVJC31Shn5nk+zaMo5kTa/Ee1aCO2yNCJMmrJ0irpcdECkbH+w4WU P7HJCOGZE/ZAzCgka9jIKtBycwk1BxVZRepihNWwb2bxjRpNvT4wegP+N iGv/SWBvxAeA88ZoD9+uGvMBp0Q4XBrkC7HNbQcQeSZ9aQWeGyYBpox1H 1ZmCoMV4J7F1krYC1RcNkAIaMpE5tRk6/MTUKz8gkg18/Ab6M9Z/O/0p6 3g4yx/BARo+zLbYeeMWTpC59E7HCHn4VQZi97nAGOsvUg7zz0gaQM4RRX w==; X-CSE-ConnectionGUID: SwKwFRe2SEOBDHa15rI5kw== X-CSE-MsgGUID: o6SMm4HPS3yLfjQJyw9mYA== X-IronPort-AV: E=Sophos;i="6.21,263,1763424000"; d="scan'208";a="11742820" Received: from ip-10-5-0-115.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.0.115]) by internal-pdx-out-012.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 17:37:57 +0000 Received: from EX19MTAUWC001.ant.amazon.com [205.251.233.105:11004] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.53.147:2525] with esmtp (Farcaster) id 3e6ee17e-ab63-4f58-8857-94cc68444b41; Fri, 30 Jan 2026 17:37:57 +0000 (UTC) X-Farcaster-Flow-ID: 3e6ee17e-ab63-4f58-8857-94cc68444b41 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:56 +0000 Received: from dev-dsk-itazur-1b-11e7fc0f.eu-west-1.amazon.com (172.19.66.53) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.35; Fri, 30 Jan 2026 17:37:54 +0000 From: Takahiro Itazuri To: , , , , , , , CC: , , , Babis Chalios , "Alexander Graf" , , Marco Cali , David Woodhouse , "Takahiro Itazuri" Subject: [PATCH v7 7/7] ptp: ptp_vmclock: return TAI not UTC Date: Fri, 30 Jan 2026 17:36:06 +0000 Message-ID: <20260130173704.12575-8-itazur@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260130173704.12575-1-itazur@amazon.com> References: <20260130173704.12575-1-itazur@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: quoted-printable X-ClientProxiedBy: EX19D038UWC004.ant.amazon.com (10.13.139.229) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Type: text/plain; charset="utf-8" From: David Woodhouse To output UTC would involve complex calculations about whether the time elapsed since the reference time has crossed the end of the month when a leap second takes effect. I've prototyped that, but it made me sad. Much better to report TAI, which is what PHCs should do anyway. And much much simpler. Signed-off-by: David Woodhouse Signed-off-by: Babis Chalios Tested-by: Takahiro Itazuri --- drivers/ptp/ptp_vmclock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c index b6e9d4c96..c7c75e19f 100644 --- a/drivers/ptp/ptp_vmclock.c +++ b/drivers/ptp/ptp_vmclock.c @@ -83,13 +83,13 @@ static uint64_t mul_u64_u64_shr_add_u64(uint64_t *res_h= i, uint64_t delta, =20 static bool tai_adjust(struct vmclock_abi *clk, uint64_t *sec) { - if (likely(clk->time_type =3D=3D VMCLOCK_TIME_UTC)) + if (clk->time_type =3D=3D VMCLOCK_TIME_TAI) return true; =20 - if (clk->time_type =3D=3D VMCLOCK_TIME_TAI && + if (clk->time_type =3D=3D VMCLOCK_TIME_UTC && (le64_to_cpu(clk->flags) & VMCLOCK_FLAG_TAI_OFFSET_VALID)) { if (sec) - *sec +=3D (int16_t)le16_to_cpu(clk->tai_offset_sec); + *sec -=3D (int16_t)le16_to_cpu(clk->tai_offset_sec); return true; } return false; @@ -350,9 +350,9 @@ static struct ptp_clock *vmclock_ptp_register(struct de= vice *dev, return NULL; } =20 - /* Only UTC, or TAI with offset */ + /* Accept TAI directly, or UTC with valid offset for conversion to TAI */ if (!tai_adjust(st->clk, NULL)) { - dev_info(dev, "vmclock does not provide unambiguous UTC\n"); + dev_info(dev, "vmclock does not provide unambiguous time\n"); return NULL; } =20 --=20 2.50.1