From owner-dev-commits-src-branches@freebsd.org Thu Sep 2 23:59:01 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4D16166A269; Thu, 2 Sep 2021 23:59:01 +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 4H0yZF0RKCz3MHW; Thu, 2 Sep 2021 23:59:00 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 96068223C1; Thu, 2 Sep 2021 23:59:00 +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 182Nx0RI011037; Thu, 2 Sep 2021 23:59:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 182Nx08D011036; Thu, 2 Sep 2021 23:59:00 GMT (envelope-from git) Date: Thu, 2 Sep 2021 23:59:00 GMT Message-Id: <202109022359.182Nx08D011036@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: cc110974c4ed - stable/12 - xen: Fix warning by adding KERNBASE to modlist_paddr before casting MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: cc110974c4edae799e2682afcd32cbfc094e6237 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Sep 2021 23:59:01 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=cc110974c4edae799e2682afcd32cbfc094e6237 commit cc110974c4edae799e2682afcd32cbfc094e6237 Author: Dimitry Andric AuthorDate: 2021-08-29 14:02:31 +0000 Commit: Dimitry Andric CommitDate: 2021-09-02 23:30:34 +0000 xen: Fix warning by adding KERNBASE to modlist_paddr before casting Clang 13 produces the following warning for hammer_time_xen(): sys/x86/xen/pv.c:183:19: error: the pointer incremented by -2147483648 refers past the last possible element for an array in 64-bit address space containing 256-bit (32-byte) elements (max possible 576460752303423488 elements) [-Werror,-Warray-bounds] (vm_paddr_t)start_info->modlist_paddr + KERNBASE; ^ ~~~~~~~~ sys/xen/interface/arch-x86/hvm/start_info.h:131:5: note: array 'modlist_paddr' declared here uint64_t modlist_paddr; /* Physical address of an array of */ ^ This is because the expression first casts start_info->modlist_paddr to struct hvm_modlist_entry * (via vmpaddr_t), and *then* adds KERNBASE, which is then interpreted as KERNBASE * sizeof(struct hvm_modlist_entry). Instead, parenthesize the addition to get the intended result, and cast it to struct hvm_modlist_entry * afterwards. Also remove the cast to vmpaddr_t since it is not necessary. Reviewed by: royger Differential Revision: https://reviews.freebsd.org/D31711 (cherry picked from commit 8e3c56d6b676a175e974bad4c20797fb35017db8) --- sys/x86/xen/pv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index e86efde1fe39..42e8c2bc73d9 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -335,7 +335,7 @@ hammer_time_xen(vm_paddr_t start_info_paddr) HYPERVISOR_shutdown(SHUTDOWN_crash); } mod = (struct hvm_modlist_entry *) - (vm_paddr_t)start_info->modlist_paddr + KERNBASE; + (start_info->modlist_paddr + KERNBASE); if (mod[0].paddr >= physfree) { xc_printf("ERROR: unexpected module memory address\n"); HYPERVISOR_shutdown(SHUTDOWN_crash);