From nobody Tue Mar 14 09:01:33 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PbSF94mvhz3xyXF; Tue, 14 Mar 2023 09:01:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PbSF93nPvz3GvN; Tue, 14 Mar 2023 09:01:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678784493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XVnjGlzzKX7uRnnhFhsdtc6/2rDm/khP8/0c7RrMuDI=; b=E4UvP8Tn8D0vr259deEcprwwfVPS2qV9B1A2X1HTT5aCBKie8lN/OzrfmXt1CpeWigNw5Q T/gMxIfLmhBKB6tWx1mUNPpy4tBhLvKTpen27sVks/wwvD8j2OdvFnSTGiZqPbp2sTpZPH SG8JS3Sa9Usb3hIdZ+oAQnOe/p3qhWUViR19CB/D9BppchqqnATFXpKMrEnxC3kp7Qjmmd MLD/0vTBqFIbcWTc1YCepR8quDWUy/7FDKXZ9/P9KYxKYIqGsNc8OPeq2W9MgNYjSAQOIl 2yjZkfcXbTqlSQheOtWxPsZbLbdu5B82RbhBGk+3Kbrknycsn5BZpYsJ2XwzTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678784493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XVnjGlzzKX7uRnnhFhsdtc6/2rDm/khP8/0c7RrMuDI=; b=TAXlF9Q58s5kBi5ouvwattqCZFbvH4tyyh1hXRzlrlBDkTnZSjQeJIsR6vyjuL5Bnd/vrI Nu231clbRXvNnwM0zGASBse8gux9hdb5JkBCuoL0rReuOgaX+X+rGRY95u5fnLStneQxDv GEGK6PCYNHY7gopmRySWOq+RO/83uV14FPrRvjXsgtzg/mtwa5+slbX10EZ/PwcAsuLZD9 zarAukKY6AYvac4AT0Hm7ao/JtGFTmEJ6GM6zbEI/PnjifJkbVMCZ645UaYND+laeiVbvZ JkacN40noKKKqf11nHc9/zozUbQSfqkWYj53vfKdYG0etvaU+0YMWxp5/zO9qw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678784493; a=rsa-sha256; cv=none; b=P7Vn0nqMwtneugoBO+mOBNls8K2cLVK3lx4fOB1nsMR9lsSSXM0+15lS0yfgRrENra/Tme 1J/VuoUSmG/RWDPmDVD84wn8Hotr843w9V1NjnQ96X6AV2EXu3d+gcNkuzw+26oNXQMbCm 7OJX+MuvGvBS0OHPmSAKwOjM6H2Saz/OxG37p+Gu+Z1ujnmHkl6IgVq0zV+uxGePRgp1zM LdJci69RELIkpt2M+bLRD7R/GaUR8gITAMzH6CkgrXcfE94HawDT3FTVg8jLt7IgBwKIFH LsznjbyF07vSx/ekYS96cxvD09BnCUPMqa+X8a0TUHVelKBu1reeFMH2KegdbQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PbSF92r2YzVGG; Tue, 14 Mar 2023 09:01:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32E91XZM033923; Tue, 14 Mar 2023 09:01:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32E91XqX033922; Tue, 14 Mar 2023 09:01:33 GMT (envelope-from git) Date: Tue, 14 Mar 2023 09:01:33 GMT Message-Id: <202303140901.32E91XqX033922@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Roger=20Pau=20Monn=C3=A9?= Subject: git: a78e46a7dbb3 - main - xen: take struct size into account for video information List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a78e46a7dbb37dcb537fbc3b17f3980458978bc9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=a78e46a7dbb37dcb537fbc3b17f3980458978bc9 commit a78e46a7dbb37dcb537fbc3b17f3980458978bc9 Author: Roger Pau Monné AuthorDate: 2023-03-13 14:17:21 +0000 Commit: Roger Pau Monné CommitDate: 2023-03-14 08:59:08 +0000 xen: take struct size into account for video information The xenpf_dom0_console_t structure can grow as more data is added, and hence we need to check that the fields we accesses have been filled by Xen. The only extra field FreeBSD currently uses is the top 32 bits for the frame buffer physical address. Note that this field is present in all the versions that make the information available from the platform hypercall interface, so the check here is mostly cosmetic, and to remember us that newly added fields require checking the size of the returned data. Fixes: 6f80738b228c ('xen: fetch dom0 video console information from Xen') Sponsored by: Citrix Systems R&D --- sys/x86/xen/pv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index d721e9bb530e..3411f4b6b030 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -347,11 +347,11 @@ fixup_console(caddr_t kmdp) struct efi_fb efi; struct vbe_fb vbe; } *fb = NULL; - int ret; + int size; - ret = HYPERVISOR_platform_op(&op); - if (ret != 0) { - xc_printf("Failed to get dom0 video console info\n"); + size = HYPERVISOR_platform_op(&op); + if (size < 0) { + xc_printf("Failed to get dom0 video console info: %d\n", size); return; } @@ -381,8 +381,11 @@ fixup_console(caddr_t kmdp) } } - fb->efi.fb_addr = console->u.vesa_lfb.lfb_base | - ((uint64_t)console->u.vesa_lfb.ext_lfb_base << 32); + fb->efi.fb_addr = console->u.vesa_lfb.lfb_base; + if (size > + offsetof(xenpf_dom0_console_t, u.vesa_lfb.ext_lfb_base)) + fb->efi.fb_addr |= + (uint64_t)console->u.vesa_lfb.ext_lfb_base << 32; fb->efi.fb_size = console->u.vesa_lfb.lfb_size << 16; fb->efi.fb_height = console->u.vesa_lfb.height; fb->efi.fb_width = console->u.vesa_lfb.width;