11 Mar, 2019

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - do not generate unneeded top-level built-in.a

    - let git ignore O= directory entirely

    - optimize scripts/kallsyms slightly

    - exclude DWARF info from *.s regardless of config options

    - fix GCC toolchain search path for Clang to prepare ld.lld support

    - do not generate modules.order when CONFIG_MODULES is disabled

    - simplify single target rules and remove VPATH for external module
    build

    - allow to add optional flags to dpkg-buildpackage when building
    deb-pkg

    - move some compiler option tests from Makefile to Kconfig

    - various Makefile cleanups

    * tag 'kbuild-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (40 commits)
    kbuild: remove scripts/basic/% build target
    kbuild: use -Werror=implicit-... instead of -Werror-implicit-...
    kbuild: clean up scripts/gcc-version.sh
    kbuild: remove cc-version macro
    kbuild: update comment block of scripts/clang-version.sh
    kbuild: remove commented-out INITRD_COMPRESS
    kbuild: move -gsplit-dwarf, -gdwarf-4 option tests to Kconfig
    kbuild: [bin]deb-pkg: add DPKG_FLAGS variable
    kbuild: move ".config not found!" message from Kconfig to Makefile
    kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing
    kbuild: simplify single target rules
    kbuild: remove empty rules for makefiles
    kbuild: make -r/-R effective in top Makefile for old Make versions
    kbuild: move tools_silent to a more relevant place
    kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig
    kbuild: refactor cc-cross-prefix implementation
    kbuild: hardcode genksyms path and remove GENKSYMS variable
    scripts/gdb: refactor rules for symlink creation
    kbuild: create symlink to vmlinux-gdb.py in scripts_gdb target
    scripts/gdb: do not descend into scripts/gdb from scripts
    ...

    Linus Torvalds
     

28 Jan, 2019

1 commit

  • In Kbuild, if_changed and friends must have FORCE as a prerequisite.

    Hence, $(filter-out FORCE,$^) or $(filter-out $(PHONY),$^) is a common
    idiom to get the names of all the prerequisites except phony targets.

    Add real-prereqs as a shorthand.

    Note:
    We cannot replace $(filter %.o,$^) in cmd_link_multi-m because $^ may
    include auto-generated dependencies from the .*.cmd file when a single
    object module is changed into a multi object module. Refer to commit
    69ea912fda74 ("kbuild: remove unneeded link_multi_deps"). I added some
    comment to avoid accidental breakage.

    Signed-off-by: Masahiro Yamada
    Acked-by: Rob Herring

    Masahiro Yamada
     

16 Jan, 2019

1 commit

  • The various x86 linker scripts use the three-argument linker script
    command variant OUTPUT_FORMAT(DEFAULT, BIG, LITTLE) which specifies
    three object file formats when the -EL and -EB linker command line
    options are used. When -EB is specified, OUTPUT_FORMAT issues the BIG
    object file format, when -EL, LITTLE, respectively, and when neither is
    specified, DEFAULT.

    However, those -E[LB] options are not used by arch/x86/ so switch to the
    simple OUTPUT_FORMAT(BFDNAME) macro variant.

    No functional changes.

    Signed-off-by: Borislav Petkov
    Cc: "H. Peter Anvin"
    Cc: x86@kernel.org
    Link: https://lkml.kernel.org/r/20190109181531.27513-1-bp@alien8.de

    Borislav Petkov
     

12 Jan, 2019

1 commit

  • The kernel uses the OUTPUT_FORMAT linker script command in it's linker
    scripts. Most of the time, the -m option is passed to the linker with
    correct architecture, but sometimes (at least for x86_64) the -m option
    contradicts the OUTPUT_FORMAT directive.

    Specifically, arch/x86/boot and arch/x86/realmode/rm produce i386 object
    files, but are linked with the -m elf_x86_64 linker flag when building
    for x86_64.

    The GNU linker manpage doesn't explicitly state any tie-breakers between
    -m and OUTPUT_FORMAT. But with BFD and Gold linkers, OUTPUT_FORMAT
    overrides the emulation value specified with the -m option.

    LLVM lld has a different behavior, however. When supplied with
    contradicting -m and OUTPUT_FORMAT values it fails with the following
    error message:

    ld.lld: error: arch/x86/realmode/rm/header.o is incompatible with elf_x86_64

    Therefore, just add the correct -m after the incorrect one (it overrides
    it), so the linker invocation looks like this:

    ld -m elf_x86_64 -z max-page-size=0x200000 -m elf_i386 --emit-relocs -T \
    realmode.lds header.o trampoline_64.o stack.o reboot.o -o realmode.elf

    This is not a functional change for GNU ld, because (although not
    explicitly documented) OUTPUT_FORMAT overrides -m EMULATION.

    Tested by building x86_64 kernel with GNU gcc/ld toolchain and booting
    it in QEMU.

    [ bp: massage and clarify text. ]

    Suggested-by: Dmitry Golovin
    Signed-off-by: George Rimar
    Signed-off-by: Tri Vo
    Signed-off-by: Borislav Petkov
    Tested-by: Tri Vo
    Tested-by: Nick Desaulniers
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: Michael Matz
    Cc: Thomas Gleixner
    Cc: morbo@google.com
    Cc: ndesaulniers@google.com
    Cc: ruiu@google.com
    Cc: x86-ml
    Link: https://lkml.kernel.org/r/20190111201012.71210-1-trong@android.com

    George Rimar
     

20 Feb, 2018

1 commit

  • Omitting suffixes from instructions in AT&T mode is bad practice when
    operand size cannot be determined by the assembler from register
    operands, and is likely going to be warned about by upstream GAS in the
    future (mine does already). Add the single missing suffix here.

    Signed-off-by: Jan Beulich
    Acked-by: Thomas Gleixner
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/5A8AF5F602000078001A9230@prv-mh.provo.novell.com
    Signed-off-by: Ingo Molnar

    Jan Beulich
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

18 Jul, 2017

1 commit

  • Add support to check if memory encryption is active in the kernel and that
    it has been enabled on the AP. If memory encryption is active in the kernel
    but has not been enabled on the AP, then set the memory encryption bit (bit
    23) of MSR_K8_SYSCFG to enable memory encryption on that AP and allow the
    AP to continue start up.

    Signed-off-by: Tom Lendacky
    Reviewed-by: Thomas Gleixner
    Reviewed-by: Borislav Petkov
    Cc: Alexander Potapenko
    Cc: Andrey Ryabinin
    Cc: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: Borislav Petkov
    Cc: Brijesh Singh
    Cc: Dave Young
    Cc: Dmitry Vyukov
    Cc: Jonathan Corbet
    Cc: Konrad Rzeszutek Wilk
    Cc: Larry Woodman
    Cc: Linus Torvalds
    Cc: Matt Fleming
    Cc: Michael S. Tsirkin
    Cc: Paolo Bonzini
    Cc: Peter Zijlstra
    Cc: Radim Krčmář
    Cc: Rik van Riel
    Cc: Toshimitsu Kani
    Cc: kasan-dev@googlegroups.com
    Cc: kvm@vger.kernel.org
    Cc: linux-arch@vger.kernel.org
    Cc: linux-doc@vger.kernel.org
    Cc: linux-efi@vger.kernel.org
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/37e29b99c395910f56ca9f8ecf7b0439b28827c8.1500319216.git.thomas.lendacky@amd.com
    Signed-off-by: Ingo Molnar

    Tom Lendacky
     

28 Nov, 2016

1 commit

  • The make variable KBUILD_CFLAGS contains $(LINUXINCLUDE). But the build
    already picks up $(LINUXINCLUDE) from scripts/Makefile.lib. The net effect
    is that the (long) list of include directories is used twice.

    This is harmless but pointless. So stop using $(LINUXINCLUDE) twice.

    Signed-off-by: Paul Bolle
    Cc: Linus Torvalds
    Cc: Masahiro Yamada
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1480077514-2586-1-git-send-email-pebolle@tiscali.nl
    Signed-off-by: Ingo Molnar

    Paul Bolle
     

19 Jul, 2016

1 commit

  • There are very few files that need add an -I$(obj) gcc for the preprocessor
    or the assembler. For C files, we add always these for both the objtree and
    srctree, but for the other ones we require the Makefile to add them, and
    Kbuild then adds it for both trees.

    As a preparation for changing the meaning of the -I$(obj) directive to
    only refer to the srctree, this changes the two instances in arch/x86 to use
    an explictit $(objtree) prefix where needed, otherwise we won't find the
    headers any more, as reported by the kbuild 0day builder.

    arch/x86/realmode/rm/realmode.lds.S:75:20: fatal error: pasyms.h: No such file or directory

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Michal Marek

    Arnd Bergmann
     

20 Apr, 2016

1 commit

  • Since commit 2aedcd098a94 ('kbuild: suppress annoying "... is up to
    date." message'), $(call if_changed,...) is evaluated to "@:"
    when there is nothing to do.

    We no longer need to add "@:" after $(call if_changed,...) to
    suppress "... is up to date." message.

    Signed-off-by: Masahiro Yamada
    Signed-off-by: Michal Marek

    Masahiro Yamada
     

23 Mar, 2016

1 commit

  • kcov provides code coverage collection for coverage-guided fuzzing
    (randomized testing). Coverage-guided fuzzing is a testing technique
    that uses coverage feedback to determine new interesting inputs to a
    system. A notable user-space example is AFL
    (http://lcamtuf.coredump.cx/afl/). However, this technique is not
    widely used for kernel testing due to missing compiler and kernel
    support.

    kcov does not aim to collect as much coverage as possible. It aims to
    collect more or less stable coverage that is function of syscall inputs.
    To achieve this goal it does not collect coverage in soft/hard
    interrupts and instrumentation of some inherently non-deterministic or
    non-interesting parts of kernel is disbled (e.g. scheduler, locking).

    Currently there is a single coverage collection mode (tracing), but the
    API anticipates additional collection modes. Initially I also
    implemented a second mode which exposes coverage in a fixed-size hash
    table of counters (what Quentin used in his original patch). I've
    dropped the second mode for simplicity.

    This patch adds the necessary support on kernel side. The complimentary
    compiler support was added in gcc revision 231296.

    We've used this support to build syzkaller system call fuzzer, which has
    found 90 kernel bugs in just 2 months:

    https://github.com/google/syzkaller/wiki/Found-Bugs

    We've also found 30+ bugs in our internal systems with syzkaller.
    Another (yet unexplored) direction where kcov coverage would greatly
    help is more traditional "blob mutation". For example, mounting a
    random blob as a filesystem, or receiving a random blob over wire.

    Why not gcov. Typical fuzzing loop looks as follows: (1) reset
    coverage, (2) execute a bit of code, (3) collect coverage, repeat. A
    typical coverage can be just a dozen of basic blocks (e.g. an invalid
    input). In such context gcov becomes prohibitively expensive as
    reset/collect coverage steps depend on total number of basic
    blocks/edges in program (in case of kernel it is about 2M). Cost of
    kcov depends only on number of executed basic blocks/edges. On top of
    that, kernel requires per-thread coverage because there are always
    background threads and unrelated processes that also produce coverage.
    With inlined gcov instrumentation per-thread coverage is not possible.

    kcov exposes kernel PCs and control flow to user-space which is
    insecure. But debugfs should not be mapped as user accessible.

    Based on a patch by Quentin Casasnovas.

    [akpm@linux-foundation.org: make task_struct.kcov_mode have type `enum kcov_mode']
    [akpm@linux-foundation.org: unbreak allmodconfig]
    [akpm@linux-foundation.org: follow x86 Makefile layout standards]
    Signed-off-by: Dmitry Vyukov
    Reviewed-by: Kees Cook
    Cc: syzkaller
    Cc: Vegard Nossum
    Cc: Catalin Marinas
    Cc: Tavis Ormandy
    Cc: Will Deacon
    Cc: Quentin Casasnovas
    Cc: Kostya Serebryany
    Cc: Eric Dumazet
    Cc: Alexander Potapenko
    Cc: Kees Cook
    Cc: Bjorn Helgaas
    Cc: Sasha Levin
    Cc: David Drysdale
    Cc: Ard Biesheuvel
    Cc: Andrey Ryabinin
    Cc: Kirill A. Shutemov
    Cc: Jiri Slaby
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dmitry Vyukov
     

29 Feb, 2016

1 commit

  • Code which runs outside the kernel's normal mode of operation often does
    unusual things which can cause a static analysis tool like objtool to
    emit false positive warnings:

    - boot image
    - vdso image
    - relocation
    - realmode
    - efi
    - head
    - purgatory
    - modpost

    Set OBJECT_FILES_NON_STANDARD for their related files and directories,
    which will tell objtool to skip checking them. It's ok to skip them
    because they don't affect runtime stack traces.

    Also skip the following code which does the right thing with respect to
    frame pointers, but is too "special" to be validated by a tool:

    - entry
    - mcount

    Also skip the test_nx module because it modifies its exception handling
    table at runtime, which objtool can't understand. Fortunately it's
    just a test module so it doesn't matter much.

    Currently objtool is the only user of OBJECT_FILES_NON_STANDARD, but it
    might eventually be useful for other tools.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/366c080e3844e8a5b6a0327dc7e8c2b90ca3baeb.1456719558.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

21 Jan, 2016

1 commit

  • UBSAN uses compile-time instrumentation to catch undefined behavior
    (UB). Compiler inserts code that perform certain kinds of checks before
    operations that could cause UB. If check fails (i.e. UB detected)
    __ubsan_handle_* function called to print error message.

    So the most of the work is done by compiler. This patch just implements
    ubsan handlers printing errors.

    GCC has this capability since 4.9.x [1] (see -fsanitize=undefined
    option and its suboptions).
    However GCC 5.x has more checkers implemented [2].
    Article [3] has a bit more details about UBSAN in the GCC.

    [1] - https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Debugging-Options.html
    [2] - https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
    [3] - http://developerblog.redhat.com/2014/10/16/gcc-undefined-behavior-sanitizer-ubsan/

    Issues which UBSAN has found thus far are:

    Found bugs:

    * out-of-bounds access - 97840cb67ff5 ("netfilter: nfnetlink: fix
    insufficient validation in nfnetlink_bind")

    undefined shifts:

    * d48458d4a768 ("jbd2: use a better hash function for the revoke
    table")

    * 10632008b9e1 ("clockevents: Prevent shift out of bounds")

    * 'x << -1' shift in ext4 -
    http://lkml.kernel.org/r/

    * undefined rol32(0) -
    http://lkml.kernel.org/r/

    * undefined dirty_ratelimit calculation -
    http://lkml.kernel.org/r/

    * undefined roundown_pow_of_two(0) -
    http://lkml.kernel.org/r/

    * [WONTFIX] undefined shift in __bpf_prog_run -
    http://lkml.kernel.org/r/

    WONTFIX here because it should be fixed in bpf program, not in kernel.

    signed overflows:

    * 32a8df4e0b33f ("sched: Fix odd values in effective_load()
    calculations")

    * mul overflow in ntp -
    http://lkml.kernel.org/r/

    * incorrect conversion into rtc_time in rtc_time64_to_tm() -
    http://lkml.kernel.org/r/

    * unvalidated timespec in io_getevents() -
    http://lkml.kernel.org/r/

    * [NOTABUG] signed overflow in ktime_add_safe() -
    http://lkml.kernel.org/r/

    [akpm@linux-foundation.org: fix unused local warning]
    [akpm@linux-foundation.org: fix __int128 build woes]
    Signed-off-by: Andrey Ryabinin
    Cc: Peter Zijlstra
    Cc: Sasha Levin
    Cc: Randy Dunlap
    Cc: Rasmus Villemoes
    Cc: Jonathan Corbet
    Cc: Michal Marek
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Yury Gribov
    Cc: Dmitry Vyukov
    Cc: Konstantin Khlebnikov
    Cc: Kostya Serebryany
    Cc: Johannes Berg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     

14 Feb, 2015

1 commit

  • This patch adds arch specific code for kernel address sanitizer.

    16TB of virtual addressed used for shadow memory. It's located in range
    [ffffec0000000000 - fffffc0000000000] between vmemmap and %esp fixup
    stacks.

    At early stage we map whole shadow region with zero page. Latter, after
    pages mapped to direct mapping address range we unmap zero pages from
    corresponding shadow (see kasan_map_shadow()) and allocate and map a real
    shadow memory reusing vmemmap_populate() function.

    Also replace __pa with __pa_nodebug before shadow initialized. __pa with
    CONFIG_DEBUG_VIRTUAL=y make external function call (__phys_addr)
    __phys_addr is instrumented, so __asan_load could be called before shadow
    area initialized.

    Signed-off-by: Andrey Ryabinin
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Cc: Dmitry Chernenkov
    Signed-off-by: Andrey Konovalov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Cc: Jim Davis
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     

16 Apr, 2014

1 commit


30 Jan, 2014

1 commit


22 Jan, 2014

1 commit


21 Jan, 2014

1 commit


07 Jan, 2014

1 commit

  • None of these files are actually using any __init type directives
    and hence don't need to include . Most are just a
    left over from __devinit and __cpuinit removal, or simply due to
    code getting copied from one driver to the next.

    [ hpa: undid incorrect removal from arch/x86/kernel/head_32.S ]

    Signed-off-by: Paul Gortmaker
    Link: http://lkml.kernel.org/r/1389054026-12947-1-git-send-email-paul.gortmaker@windriver.com
    Signed-off-by: H. Peter Anvin

    Paul Gortmaker
     

10 Dec, 2013

1 commit

  • In checkin

    5551a34e5aea x86-64, build: Always pass in -mno-sse

    we unconditionally added -mno-sse to the main build, to keep newer
    compilers from generating SSE instructions from autovectorization.
    However, this did not extend to the special environments
    (arch/x86/boot, arch/x86/boot/compressed, and arch/x86/realmode/rm).
    Add -mno-sse to the compiler command line for these environments, and
    add -mno-mmx to all the environments as well, as we don't want a
    compiler to generate MMX code either.

    This patch also removes a $(cc-option) call for -m32, since we have
    long since stopped supporting compilers too old for the -m32 option,
    and in fact hardcode it in other places in the Makefiles.

    Reported-by: Kevin B. Smith
    Cc: Sunil K. Pandey
    Signed-off-by: H. Peter Anvin
    Cc: H. J. Lu
    Link: http://lkml.kernel.org/n/tip-j21wzqv790q834n7yc6g80j1@git.kernel.org
    Cc: # build fix only

    H. Peter Anvin
     

02 Oct, 2012

1 commit

  • The patch:

    73201dbe x86, suspend: On wakeup always initialize cr4 and EFER

    ... was incorrectly committed in an intermediate (unfinished) form.

    - We need to test CF, not ZF, for a bit test with btl.
    - We don't actually need to compute the existence of EFLAGS.ID,
    since we set a flag at suspend time if CR4 should be restored.

    Signed-off-by: H. Peter Anvin
    Cc: Rafael J. Wysocki
    Link: http://lkml.kernel.org/r/1348529239-17943-1-git-send-email-hpa@linux.intel.com
    Signed-off-by: Ingo Molnar

    H. Peter Anvin
     

27 Sep, 2012

1 commit

  • We already have a flag word to indicate the existence of MISC_ENABLES,
    so use the same flag word to indicate existence of cr4 and EFER, and
    always restore them if they exist. That way if something passes a
    nonzero value when the value *should* be zero, we will still
    initialize it.

    Signed-off-by: H. Peter Anvin
    Cc: Rafael J. Wysocki
    Link: http://lkml.kernel.org/r/1348529239-17943-1-git-send-email-hpa@linux.intel.com

    H. Peter Anvin
     

11 Aug, 2012

1 commit

  • GCC built with nonstandard options can enable -fpic by default.
    We never want this for 32-bit kernels and it will break the build.

    [ hpa: Notably the Android toolchain apparently does this. ]

    Change-Id: Iaab7d66e598b1c65ac4a4f0229eca2cd3d0d2898
    Signed-off-by: Andrew Boie
    Link: http://lkml.kernel.org/r/1344624546-29691-1-git-send-email-andrew.p.boie@intel.com
    Signed-off-by: H. Peter Anvin

    Andrew Boie
     

22 Jun, 2012

1 commit

  • Be a bit more paranoid in the transition back to 16-bit mode. In
    particular, in case the kernel is residing above the 4 GiB mark,
    switch to the trampoline GDT, and make the jump after turning off
    paging a far jump. In theory, none of this should matter, but it is
    exactly the kind of things that broken SMM or virtualization software
    could trip up on.

    Signed-off-by: H. Peter Anvin
    Link: http://lkml.kernel.org/r/tip-jopx7y6g6dbcx4tpal8q0jlr@git.kernel.org

    H. Peter Anvin
     

18 Jun, 2012

1 commit


21 May, 2012

1 commit

  • The end signature was defined in wakeup_asm.S as it originally came
    from the ACPI wakeup code. However, we rely on the existence of the
    .signature section to expand .bss, otherwise we would have to include
    code to explicitly zero the .bss depending on the configuration.
    Since the expanded .bss is just in .init.data anyway, it's easier to
    always have it expanded.

    This fixes failures when compiled without CONFIG_ACPI_SLEEP.

    Reported-by: Ingo Molnar
    Signed-off-by: H. Peter Anvin
    Cc: Jarkko Sakkinen

    H. Peter Anvin
     

17 May, 2012

2 commits

  • Change EFER to be a single u64 field instead of two u32 fields; change
    the order to maintain alignment. Note that on x86-64 cr4 is really
    also a 64-bit quantity, although we can only set the low 32 bits from
    the trampoline code since it is still executing in 32-bit mode at that
    point.

    Signed-off-by: H. Peter Anvin
    Cc: Jarkko Sakkinen

    H. Peter Anvin
     
  • Move the bits that aren't actually common out of trampoline_common.S
    and into the arch-specific files. Furthermore, make sure the page
    directory is first in the .bss section for trampoline_64.S in order to
    not waste an entire page of memory.

    Signed-off-by: H. Peter Anvin
    Cc: Jarkko Sakkinen

    H. Peter Anvin
     

11 May, 2012

1 commit

  • Before the new real-mode code infrastructure %edx was
    used for testing CD and NW bits with andl in order to
    decide whether to flush the processor caches or not.
    The value of cr0 was also stored in %eax, which was
    later used to set cr0 after masking out lower byte
    (except TS bit) in order to enter real-mode.

    In the new real-mode code infrastructure we wanted to
    keep input parameter in %eax so we are using %edx for
    both cr0 cases. This has caused regression since andl
    overwrites the value of %edx.

    This patch fixes the issue by replacing andl with testl,
    which is essentially andl without writing result to the
    register.

    Special thanks to Paolo Bonzini for noting this and
    proposing a fix.

    Reported-and-tested-by: Paolo Bonzini
    Signed-off-by: Jarkko Sakkinen
    Link: http://lkml.kernel.org/r/1336633898-23743-1-git-send-email-jarkko.sakkinen@intel.com
    Signed-off-by: H. Peter Anvin

    Jarkko Sakkinen
     

10 May, 2012

2 commits

  • Kbuild expects all generated files to be listed in the targets
    variable. If it isn't, weird things happen.

    Cc: Sam Ravnborg
    Cc: Michal Marek
    Signed-off-by: H. Peter Anvin
    Link: http://lkml.kernel.org/r/1336595106-21135-1-git-send-email-jarkko.sakkinen@intel.com

    H. Peter Anvin
     
  • Real-mode binary was built twice. This patch fixes
    the issue by making realmode.relocs as target for
    realmode.bin.

    [ hpa: removed the direct dependency on realmode.relocs in
    arch/x86/realmode/Makefile ]

    Signed-off-by: Jarkko Sakkinen
    Link: http://lkml.kernel.org/r/1336595106-21135-1-git-send-email-jarkko.sakkinen@intel.com
    Cc: Sam Ravnborg
    Cc: Michal Marek
    Signed-off-by: H. Peter Anvin

    Jarkko Sakkinen
     

09 May, 2012

9 commits

  • This patch changes 64-bit trampoline so that CR4 and
    EFER are provided by the kernel instead of using fixed
    values.

    Signed-off-by: Jarkko Sakkinen
    Link: http://lkml.kernel.org/r/1336501366-28617-24-git-send-email-jarkko.sakkinen@intel.com
    Signed-off-by: H. Peter Anvin

    Jarkko Sakkinen
     
  • Moved relocs tool from scripts/ to arch/x86/tools because
    it is architecture specific script. Added new target archscripts
    that can be used to build scripts needed building an architecture.

    Signed-off-by: Jarkko Sakkinen
    Link: http://lkml.kernel.org/r/1336501366-28617-22-git-send-email-jarkko.sakkinen@intel.com
    Signed-off-by: H. Peter Anvin
    Cc: Sam Ravnborg
    Cc: Michal Marek

    Jarkko Sakkinen
     
  • Added header for trampoline code that can be used to supply
    input data to it. This makes interface between real mode code
    and kernel cleaner and simpler. Replaced two confusing pointers
    to level4 pgt in trampoline_64.S with a single pointer to the
    beginning of the page table.

    Signed-off-by: Jarkko Sakkinen
    Link: http://lkml.kernel.org/r/1336501366-28617-21-git-send-email-jarkko.sakkinen@intel.com
    Signed-off-by: H. Peter Anvin

    Jarkko Sakkinen
     
  • Simplified hierarchy under rm directory to a flat
    directory because it is not anymore really justified
    to have own directory for wakeup code. It only adds
    more complexity.

    Signed-off-by: Jarkko Sakkinen
    Link: http://lkml.kernel.org/r/1336501366-28617-20-git-send-email-jarkko.sakkinen@intel.com
    Signed-off-by: H. Peter Anvin

    Jarkko Sakkinen
     
  • Replaced copying of real_mode_header with a pointer
    to beginning of RM memory.

    Signed-off-by: Jarkko Sakkinen
    Link: http://lkml.kernel.org/r/1336501366-28617-19-git-send-email-jarkko.sakkinen@intel.com
    Signed-off-by: H. Peter Anvin

    Jarkko Sakkinen
     
  • There were number of issues in wakeup sequence:

    - Wakeup stack was placed in hardcoded address.
    - NX bit in EFER was not enabled.
    - Initialization incorrectly set physical address
    of secondary_startup_64.
    - Some alignment issues.

    This patch fixes these issues and in addition:

    - Unifies coding conventions in .S files.
    - Sets alignments of code and data right.

    Signed-off-by: Jarkko Sakkinen
    Link: http://lkml.kernel.org/r/1336501366-28617-18-git-send-email-jarkko.sakkinen@intel.com
    Originally-by: H. Peter Anvin
    Cc: Rafael J. Wysocki
    Cc: Len Brown
    Signed-off-by: H. Peter Anvin

    Jarkko Sakkinen
     
  • A test instruction is an "and", and an and with zero is always zero.
    This would cause us to always take the BIOS path, not the APM path, in
    case anyone actually cares...

    Signed-off-by: H. Peter Anvin
    Link: http://lkml.kernel.org/r/1336501366-28617-17-git-send-email-jarkko.sakkinen@intel.com

    H. Peter Anvin
     
  • Move trampoline_*.S earlier in the link order so it ends up being
    first in the text segment; since the SIPI vector requires 4K alignment
    it otherwise ends up padding the .text segment with that much
    completely unnecessarily.

    Signed-off-by: H. Peter Anvin
    Link: http://lkml.kernel.org/r/1336501366-28617-16-git-send-email-jarkko.sakkinen@intel.com

    H. Peter Anvin
     
  • We cannot code an ljmpw to the real-mode segment directly, because gas
    refuses to assemble an ljmp with a symbolic segment. Instead of
    open-coding it everywhere, define a macro and use it for this case.

    This is specifically an ljmpw from a 16-bit segment. This is okay, as
    one should never enter real mode from a 32-bit segment: if one do, the
    CPU ends up in a bizarre (and useless) mode sometimes called "unreal
    mode" where segments behave like real mode but the default address and
    operand sizes is 32 bits.

    Signed-off-by: H. Peter Anvin
    Link: http://lkml.kernel.org/r/1336501366-28617-15-git-send-email-jarkko.sakkinen@intel.com

    H. Peter Anvin