[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] ns16550: MMIO r/o ranges are maintained at page granularity
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Mon, 30 Aug 2021 15:05:49 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5CJMcRsTP8YiUEVz+XgCP0XZj5R61TCRxya50P2tErc=; b=bfo6wZd+At0HsS8x5aGlcgxwke1Fd5lhG3qJ8wMDitjhsGsydkYymeXUQtufijfMjnSiejcTUzgnUe1pNOpwQaqnLWhqA48JauSeDqI+nF2OXjMV+x2/FsrQ9gI57QHOsKHLorINs2QCGZr7IyVwsw+tVpSN5HKBBU13qzJPL+1w/hEHAp09OKPN2EVev3aagpdcp1PSB8U0o3JNc5qjzC89rCcLaKwpJ0ommfq49x9LOPNf4SPS2h4vs5kIS605N5UEMLwbgWEK3MrHxKMrjQiCPFEiVJrIIQMLqLQ9UIu3JgQE+DrXtSYX6VCr6JtfdDbuwkEHUupQak+b647bpQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7Sx/7KVuNeZaizlLP6k+TKAipFhOdNYSERH100VRwTDeq/m39NtlAVSZxHF9eFY0oGIJ30ZV5STWgcSjjYd4TQQz2afMBaL3Rwul4MraZ4kggNf54/nn7XB6kEjjQBi1TW5so86x2FfZRB1+7UpSglrsh/IyGF5tUXZ9l1zydniLDXpU5wXsbUkzt5Ghc/E0uibIqQ+gUspg6Oyh9aERg+v4nZb3vsUEJ/Qv4bmer0lXqiTbKSZHVhToK+u5oswsJIJoLsEo0XkZ2p/RY0r9VupERxRGLm9mltmsTFZsFK5LwOlslLZVB2QmXL6t7eOZAKJbx31TTMJtqHsMtAhdA==
- Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Mon, 30 Aug 2021 13:05:57 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Passing byte granular values will not have the intended effect. Address
the immediate issue, but I don't think what we do is actually
sufficient: At least some devices allow access to their registers via
either I/O ports or MMIO. In such aliasing cases we'd need to protect
the MMIO range even when we use I/O port accesses to drive the port.
Note that this way we may write-protect MMIO ranges of unrelated devices
as well. To deal with this, faults resulting from this would need
handling, to emulate the accesses outside of the protected range. (An
alternative would be to relocate the BAR, but I'm afraid this might end
up even more challenging.)
Fixes: c9f8e0aee507 ("ns16550: Add support for UART present in Broadcom
TruManage capable NetXtreme chips")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -421,8 +421,8 @@ static void __init ns16550_init_postirq(
if ( uart->bar || uart->ps_bdf_enable )
{
if ( uart->param && uart->param->mmio &&
- rangeset_add_range(mmio_ro_ranges, uart->io_base,
- uart->io_base + uart->io_size - 1) )
+ rangeset_add_range(mmio_ro_ranges, PFN_DOWN(uart->io_base),
+ PFN_UP(uart->io_base + uart->io_size) - 1) )
printk(XENLOG_INFO "Error while adding MMIO range of device to
mmio_ro_ranges\n");
if ( pci_ro_device(0, uart->ps_bdf[0],
|