From owner-svn-src-head@freebsd.org Wed Nov 25 23:19:03 2020 Return-Path: Delivered-To: svn-src-head@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 3B454476ACA; Wed, 25 Nov 2020 23:19:03 +0000 (UTC) (envelope-from sobomax@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ChGzq19skz4c0k; Wed, 25 Nov 2020 23:19:03 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1B4E5192F9; Wed, 25 Nov 2020 23:19:03 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0APNJ2br030343; Wed, 25 Nov 2020 23:19:02 GMT (envelope-from sobomax@FreeBSD.org) Received: (from sobomax@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0APNJ2sT030338; Wed, 25 Nov 2020 23:19:02 GMT (envelope-from sobomax@FreeBSD.org) Message-Id: <202011252319.0APNJ2sT030338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sobomax set sender to sobomax@FreeBSD.org using -f From: Maxim Sobolev Date: Wed, 25 Nov 2020 23:19:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368041 - in head: stand/efi/loader sys/amd64/amd64 sys/amd64/include sys/conf X-SVN-Group: head X-SVN-Commit-Author: sobomax X-SVN-Commit-Paths: in head: stand/efi/loader sys/amd64/amd64 sys/amd64/include sys/conf X-SVN-Commit-Revision: 368041 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2020 23:19:03 -0000 Author: sobomax Date: Wed Nov 25 23:19:01 2020 New Revision: 368041 URL: https://svnweb.freebsd.org/changeset/base/368041 Log: Unobfuscate "KERNLOAD" parameter on amd64. This change lines-up amd64 with the i386 and the rest of supported architectures by defining KERNLOAD in the vmparam.h and getting rid of magic constant in the linker script, which albeit documented via comment but isn't programmatically accessible at a compile time. Use KERNLOAD to eliminate another (matching) magic constant 100 lines down inside unremarkable TU "copy.c" 3 levels deep in the EFI loader tree. Reviewed by: markj Approved by: markj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D27355 Modified: head/stand/efi/loader/copy.c head/sys/amd64/amd64/genassym.c head/sys/amd64/amd64/locore.S head/sys/amd64/include/vmparam.h head/sys/conf/ldscript.amd64 Modified: head/stand/efi/loader/copy.c ============================================================================== --- head/stand/efi/loader/copy.c Wed Nov 25 23:17:23 2020 (r368040) +++ head/stand/efi/loader/copy.c Wed Nov 25 23:19:01 2020 (r368041) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #if defined(__i386__) || defined(__amd64__) #include #include +#include /* * The code is excerpted from sys/x86/x86/identcpu.c: identify_cpu(), @@ -89,8 +90,6 @@ running_on_hyperv(void) return (1); } -#define KERNEL_PHYSICAL_BASE (2*1024*1024) - static void efi_verify_staging_size(unsigned long *nr_pages) { @@ -134,12 +133,11 @@ efi_verify_staging_size(unsigned long *nr_pages) start = p->PhysicalStart; end = start + p->NumberOfPages * EFI_PAGE_SIZE; - if (KERNEL_PHYSICAL_BASE < start || - KERNEL_PHYSICAL_BASE >= end) + if (KERNLOAD < start || KERNLOAD >= end) continue; available_pages = p->NumberOfPages - - ((KERNEL_PHYSICAL_BASE - start) >> EFI_PAGE_SHIFT); + ((KERNLOAD - start) >> EFI_PAGE_SHIFT); break; } Modified: head/sys/amd64/amd64/genassym.c ============================================================================== --- head/sys/amd64/amd64/genassym.c Wed Nov 25 23:17:23 2020 (r368040) +++ head/sys/amd64/amd64/genassym.c Wed Nov 25 23:19:01 2020 (r368041) @@ -115,6 +115,7 @@ ASSYM(val_KPML4I, KPML4I); ASSYM(val_PML4PML4I, PML4PML4I); ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS); ASSYM(KERNBASE, KERNBASE); +ASSYM(KERNLOAD, KERNLOAD); ASSYM(DMAP_MIN_ADDRESS, DMAP_MIN_ADDRESS); ASSYM(DMAP_MAX_ADDRESS, DMAP_MAX_ADDRESS); Modified: head/sys/amd64/amd64/locore.S ============================================================================== --- head/sys/amd64/amd64/locore.S Wed Nov 25 23:17:23 2020 (r368040) +++ head/sys/amd64/amd64/locore.S Wed Nov 25 23:19:01 2020 (r368041) @@ -36,8 +36,9 @@ /* * Compiled KERNBASE location */ - .globl kernbase, loc_PTmap, loc_PDmap, loc_PDPmap, dmapbase, dmapend + .globl kernbase, kernload, loc_PTmap, loc_PDmap, loc_PDPmap, dmapbase, dmapend .set kernbase,KERNBASE + .set kernload,KERNLOAD .set dmapbase,DMAP_MIN_ADDRESS .set dmapend,DMAP_MAX_ADDRESS Modified: head/sys/amd64/include/vmparam.h ============================================================================== --- head/sys/amd64/include/vmparam.h Wed Nov 25 23:17:23 2020 (r368040) +++ head/sys/amd64/include/vmparam.h Wed Nov 25 23:19:01 2020 (r368041) @@ -149,6 +149,14 @@ #endif /* + * Kernel physical load address. Needs to be aligned at 2MB superpage + * boundary. + */ +#ifndef KERNLOAD +#define KERNLOAD 0x200000 +#endif + +/* * Virtual addresses of things. Derived from the page directory and * page table indexes from pmap.h for precision. * Modified: head/sys/conf/ldscript.amd64 ============================================================================== --- head/sys/conf/ldscript.amd64 Wed Nov 25 23:17:23 2020 (r368040) +++ head/sys/conf/ldscript.amd64 Wed Nov 25 23:19:01 2020 (r368041) @@ -5,8 +5,8 @@ ENTRY(btext) SEARCH_DIR("/usr/lib"); SECTIONS { + kernphys = kernload; /* Read-only sections, merged into text segment: */ - kernphys = 0x200000; /* 2MB superpage size */ . = kernbase + kernphys + SIZEOF_HEADERS; /* * Use the AT keyword in order to set the right LMA that contains