├── aos ├── plat │ └── tegra │ │ └── Makefile ├── include │ ├── plat-tegra │ │ └── plat-tegra │ ├── Makefile │ ├── stdarg.h │ ├── asm-arm │ │ ├── linkage.h │ │ ├── types.h │ │ ├── system.h │ │ ├── div64.h │ │ └── stdarg.h │ ├── lib │ │ ├── vsprintf.h │ │ ├── ctype.h │ │ └── string.h │ ├── bug.h │ ├── system.h │ ├── defines.h │ ├── linkage.h │ ├── types.h │ └── div64.h ├── lib │ ├── Makefile │ └── ctype.c ├── arch │ └── arm │ │ ├── Makefile │ │ ├── Rules.mk │ │ ├── c_entry.c │ │ ├── aos.lds │ │ ├── entry.S │ │ └── div64.S ├── Config.mk ├── README ├── Makefile └── Rules.mk ├── cv └── resume.pdf ├── xen ├── arm │ ├── 4.2-arm.diff │ └── README └── ovmf-support │ ├── README │ └── ovmf-xend-unstable-4.2.patch ├── qemu ├── esxi-arm │ ├── get_latest_uefi.sh │ ├── runme │ └── 0001-Work-arounds-for-running-ESXi-Arm-at-EL2-without-TF-.patch ├── 0001-qemu-fix-page_check_range.patch ├── 0003-x86-implement-EXCP_TB_EFAULT.patch ├── tests │ ├── sigtest_mprotect.c │ └── sigtest.c └── 0002-qemu-handle-tb_gen_code-getting-called-for-unmapped-.patch ├── uefi ├── GSoC2012 │ ├── README │ ├── 0003-OVMF-Enable-building-MPTest.patch │ ├── 0004-Compiler-Fixes-to-get-UEFI-building-for-me.patch │ ├── 0001-MPS-Test-program-for-the-protocol-implementation.patch │ └── 0002-UefiCpuPkg-MP-Support-WIP.patch ├── DebugPkg │ └── GdbSyms │ │ ├── GdbSyms.inf │ │ └── GdbSyms.c └── 0001-ArmPkg-DebugPeCoffExtraActionLib.patch ├── README ├── linux ├── 3.2 │ ├── block │ │ ├── dm │ │ │ └── 0001-DM-Minor-fix-to-dm-snap-metadata-backend-registratio.patch │ │ ├── md │ │ │ ├── raid1_resync_graveyard │ │ │ │ ├── README │ │ │ │ └── 0001-MD-Bitmap-version-cleanup.patch │ │ │ └── 0001-MD-Allow-restarting-an-interrupted-incremental-recov.patch │ │ └── loop │ │ │ ├── attic │ │ │ ├── 0003-Loop-Allow-file-I-O-to-kernel-buffers.patch │ │ │ ├── 0005-Loop-Cleanup-parser-matching-logic.patch │ │ │ ├── 0011-Loop-Cleanup-loop-size-computation.patch │ │ │ ├── 0010-Loop-Implement-parser-I-O-accessor.patch │ │ │ ├── 0012-Loop-Allow-parser-to-notify-loop-if-losetup-should-f.patch │ │ │ ├── 0001-Loop-Allow-non-linear-mapping-between-loop-and-backi.patch │ │ │ ├── 0007-Loop-Expose-transfer-parameter-into-send-receive-fun.patch │ │ │ ├── 0006-Loop-Propagate-lo_file-into-lo_send-lo_receive-path.patch │ │ │ └── 0008-Loop-Allow-internal-untransformed-direct-file-I-O.patch │ │ │ └── README │ ├── 0002-include-log2.h-Fix-rounddown_pow_of_two-1.patch │ ├── olpc │ │ └── fiq │ │ │ ├── 0004-MMP2-FIQ-debugger-support-for-the-XO-1.75.patch │ │ │ ├── 0001-MMP2-Enable-FIQ-support.patch │ │ │ ├── README │ │ │ └── 0005-Kernel-Rename-kdb_syslog_data-and-separate-from-KDB-.patch │ ├── 0001-dev-mem-Fix-wrong-error-on-accessing-beyond-valid-me.patch │ ├── 0001-VMW_PVSCSI-Allow-TCQ-depth-change-through-sysfs.patch │ ├── kgdb │ │ ├── 0003-NETPOLL-Extend-rx_hook-support.patch │ │ ├── 0001-KDB-Make-LINES-an-internal-variable.patch │ │ ├── 0007-x86-NMI-Be-smarter-about-invoking-panic-inside-NMI-h.patch │ │ ├── 0002-KDB-Overide-LINES-for-custom-commands.patch │ │ └── 0006-KDB-Fix-usability-issues-relating-to-the-enter-key.patch │ └── pe32+ │ │ └── hello.asm ├── 2.6.36 │ ├── android-tegra │ │ ├── 0001-Tegra-Lockdepify-clock.c.patch │ │ └── 0002-Tegra-Fix-lockdep-warning-in-cpu-idle.c.patch │ └── 0001-BlueZ-HCI-Be-more-resilient-to-HCI-protocol-problems.patch └── 3.0 │ └── mmc │ ├── cmd23 │ ├── 0006-MMC-SDHCI-Auto-CMD23-fixes.patch │ ├── 0001-MMC-Add-remove-quirks-conditional-support.patch │ ├── 0004-MMC-Block-CMD23-support-for-UHS104-SDXC-cards.patch │ ├── 0005-MMC-SDHCI-AutoCMD23-support.patch │ └── 0003-MMC-Implement-MMC_CAP_CMD23-for-SDHCI.patch │ └── 0001-MMC-Safe-remove.patch └── git └── 0001-Git-p4-Add-git-p4-change-command.patch /aos/plat/tegra/Makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /aos/include/plat-tegra/plat-tegra: -------------------------------------------------------------------------------- 1 | plat-tegra -------------------------------------------------------------------------------- /cv/resume.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreiw/andreiw-wip/HEAD/cv/resume.pdf -------------------------------------------------------------------------------- /aos/lib/Makefile: -------------------------------------------------------------------------------- 1 | OBJECTS-y += ctype.o 2 | OBJECTS-y += string.o 3 | OBJECTS-y += vsprintf.o -------------------------------------------------------------------------------- /xen/arm/4.2-arm.diff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andreiw/andreiw-wip/HEAD/xen/arm/4.2-arm.diff -------------------------------------------------------------------------------- /aos/include/Makefile: -------------------------------------------------------------------------------- 1 | clean:: 2 | rm -f *~ 3 | rm -f lib/*~ 4 | rm -f asm/*~ 5 | rm -f plat/*~ 6 | rm -f asm 7 | rm -f plat 8 | -------------------------------------------------------------------------------- /aos/arch/arm/Makefile: -------------------------------------------------------------------------------- 1 | OBJECTS-y += entry.o 2 | OBJECTS-y += c_entry.o 3 | OBJECTS-y += div64.o 4 | 5 | kernel: $(ALL_OBJECTS-y) aos.lds 6 | $(LD) $(LDFLAGS) -T aos.lds -N -Map $@.map $(ALL_OBJECTS-y) -o $@.o 7 | $(OBJCOPY) -O binary $@.o $@ 8 | 9 | clean:: 10 | rm -f *.map kernel -------------------------------------------------------------------------------- /aos/Config.mk: -------------------------------------------------------------------------------- 1 | ARCH ?= arm 2 | PLAT ?= tegra 3 | CROSS_COMPILE = arm-eabi- 4 | 5 | # 6 | # If you change any of these configuration options then you must 7 | # 'make clean' before rebuilding. 8 | # 9 | 10 | verbose ?= n 11 | debug ?= n 12 | frame_pointer ?= n 13 | 14 | -------------------------------------------------------------------------------- /aos/arch/arm/Rules.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Arch. 3 | # 4 | 5 | CFLAGS += -march=armv7-a -mlittle-endian -mabi=aapcs -mapcs 6 | CLFAGS += -fpic 7 | CFLAGS += -fno-builtin -fno-common 8 | CFLAGS += -iwithprefix include -pipe 9 | CFLAGS += -msoft-float 10 | CFLAGS += -Wa,--fatal-warnings -Werror -Wno-uninitialized 11 | LDFLAGS += -nostdlib 12 | -------------------------------------------------------------------------------- /qemu/esxi-arm/get_latest_uefi.sh: -------------------------------------------------------------------------------- 1 | rm -f flash0.img 2 | rm -f flash1.img 3 | rm -f QEMU_EFI.fd 4 | wget http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd 5 | dd if=/dev/zero of=flash0.img bs=1M count=64 6 | dd if=QEMU_EFI.fd of=flash0.img conv=notrunc 7 | dd if=/dev/zero of=flash1.img bs=1M count=64 8 | -------------------------------------------------------------------------------- /uefi/GSoC2012/README: -------------------------------------------------------------------------------- 1 | These were some ongoing helpful patches I was 2 | putting together for a GSoC'12 Tiano Core 3 | project I was co-mentoring on implementing 4 | the MP support protocol in OVMF. 5 | 6 | I wonder what happened to jljusten's similar 7 | work... 8 | 9 | Since it's unlikely I'll return to these anytime 10 | soon, they might as well live here instead of 11 | a separate dead edk2 tree. -------------------------------------------------------------------------------- /aos/arch/arm/c_entry.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | void __div0 (void) 10 | { 11 | while (1); 12 | } 13 | 14 | void c_entry (void) 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /aos/include/stdarg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_STDARG_H 10 | #define AOS_STDARG_H 11 | 12 | #include 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /aos/include/asm-arm/linkage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_ARM_LINKAGE_H 10 | #define AOS_ARM_LINKAGE_H 11 | 12 | #define ENDPROC(name) \ 13 | .type name, %function; \ 14 | END(name) 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /aos/include/lib/vsprintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_LIB_VSPRINTF_H 10 | #define AOS_LIB_VSPRINTF_H 11 | 12 | struct va_format { 13 | const char *fmt; 14 | va_list *va; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /aos/include/bug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_BUG_H 10 | #define AOS_BUG_H 11 | 12 | #include 13 | 14 | #define BUG() 15 | 16 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /aos/arch/arm/aos.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-littlearm") 2 | OUTPUT_ARCH(arm) 3 | ENTRY(_aos_entry) 4 | 5 | SECTIONS 6 | { 7 | . = 0; 8 | _text = .; 9 | 10 | .text : { 11 | *(.start) 12 | *(.text) 13 | *(.text.*) 14 | *(.fixup) 15 | *(.data) 16 | *(.rodata) 17 | *(.rodata.*) 18 | *(.glue_7) 19 | *(.glue_7t) 20 | . = ALIGN(4); 21 | } 22 | 23 | _got_start = .; 24 | .got : { *(.got) } 25 | _got_end = .; 26 | 27 | . = ALIGN(4); 28 | .bss : { *(.bss) } 29 | _end = .; 30 | } 31 | -------------------------------------------------------------------------------- /aos/include/system.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_SYSTEM_H 10 | #define AOS_SYSTEM_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #endif /* AOS_SYSTEM_H */ 19 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Andrei Warkentin's Work-in-Progress 2 | =================================== 3 | 4 | Actually, this is more like a cemetary for stuff 5 | that is/was/could be useful, but doesn't really live 6 | elsewhere. 7 | 8 | Aside from my old and still not updated resume, there's 9 | some old Linux work that I've done (but that is now 10 | probably hopelessly out of date). 11 | 12 | Maybe I'll move some more decrepit stuff here from my 13 | college archives ;-). 14 | 15 | Contact Info 16 | ============ 17 | 18 | Andrei Warkentin (andrey.warkentin@gmail.com, andreiw@vmware.com) -------------------------------------------------------------------------------- /qemu/esxi-arm/runme: -------------------------------------------------------------------------------- 1 | ISO=/hgfs/Desktop/VMware-VMvisor-Installer-7.0.0-17068872.aarch64.iso 2 | DISK=/hgfs/Desktop/disk.img 3 | 4 | ./build/aarch64-softmmu/qemu-system-aarch64 -M virt -machine virtualization=on -cpu cortex-a57 \ 5 | -m 4G -smp 2 -pflash flash0.img -pflash flash1.img -serial stdio -device ramfb \ 6 | -device usb-ehci,id=ehci -device usb-kbd \ 7 | -drive if=none,id=iso,file=$ISO -device usb-storage,bus=ehci.0,drive=iso \ 8 | -drive if=none,id=disk,file=$DISK -device usb-storage,bus=ehci.0,drive=disk \ 9 | -device e1000e,netdev=net0 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -------------------------------------------------------------------------------- /aos/README: -------------------------------------------------------------------------------- 1 | AOS 2 | === 3 | 4 | This is a simple example of how one would go about writing some stand-alone 5 | code, meant to be booted by a Linux-compatible ARM bootloader. This particular 6 | bit uses PIC-compiled code, and fixes up relocations and run-time, so there 7 | is no need to know where it was loaded. 8 | 9 | Building: 10 | $ CROSS_COMPILE=arm-eabi- make 11 | 12 | Booting (assuming Android): 13 | $ fastboot boot boot/aos 14 | 15 | Running (assuming Tegra 2, UARTB): 16 | 01234 17 | DEAD 18 | 19 | Contact Info 20 | ============ 21 | 22 | Andrei Warkentin (andrey.warkentin@gmail.com, andreiw@vmware.com, andreiw@msalumni.com) -------------------------------------------------------------------------------- /aos/include/defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_DEFINES_H 10 | #define AOS_DEFINES_H 11 | 12 | #ifndef likely 13 | #define likely(x) (__builtin_constant_p(x) ? !!(x) : __builtin_expect(!!(x), 1)) 14 | #endif 15 | #ifndef unlikely 16 | #define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __builtin_expect(!!(x), 0)) 17 | #endif 18 | 19 | #endif /* AOS_DEFINES_H */ 20 | -------------------------------------------------------------------------------- /aos/include/asm-arm/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_ARM_TYPES_H 10 | #define AOS_ARM_TYPES_H 11 | 12 | typedef signed char s8; 13 | typedef unsigned char u8; 14 | 15 | typedef signed short s16; 16 | typedef unsigned short u16; 17 | 18 | typedef signed long s32; 19 | typedef unsigned long u32; 20 | 21 | typedef signed long long s64; 22 | typedef unsigned long long u64; 23 | 24 | typedef s32 sN; 25 | typedef u32 uN; 26 | 27 | typedef u32 paddr_t; 28 | typedef u32 vaddr_t; 29 | 30 | #endif /* AOS_ARM_TYPES_H */ 31 | -------------------------------------------------------------------------------- /aos/Makefile: -------------------------------------------------------------------------------- 1 | include Config.mk 2 | 3 | export ARCH ?= none 4 | export PLAT ?= none 5 | export CROSS_COMPILE 6 | export BASEDIR=$(CURDIR) 7 | 8 | all: 9 | @echo 10 | @echo Building for $(ARCH)-$(PLAT) 11 | @echo ------------------------------------------------------------ 12 | @echo 13 | ln -sf asm-$(ARCH) include/asm 14 | ln -sf plat-$(PLAT) include/plat 15 | $(MAKE) -f $(BASEDIR)/Rules.mk -C lib built_in.o 16 | $(MAKE) -f $(BASEDIR)/Rules.mk -C plat/$(PLAT) built_in.o 17 | $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(ARCH) built_in.o 18 | $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(ARCH) kernel 19 | 20 | clean: 21 | rm -f *~ 22 | $(MAKE) -f $(BASEDIR)/Rules.mk -C include clean 23 | $(MAKE) -f $(BASEDIR)/Rules.mk -C lib clean 24 | $(MAKE) -f $(BASEDIR)/Rules.mk -C plat/$(PLAT) clean 25 | $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(ARCH) clean 26 | -------------------------------------------------------------------------------- /uefi/GSoC2012/0003-OVMF-Enable-building-MPTest.patch: -------------------------------------------------------------------------------- 1 | From ec1eb393ceb9432f572a7554e70f59c92354aca2 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sat, 21 Apr 2012 00:20:40 -0400 4 | Subject: [PATCH 3/5] OVMF: Enable building MPTest 5 | 6 | For WIP MPS work. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | OvmfPkg/OvmfPkgX64.dsc | 2 ++ 11 | 1 file changed, 2 insertions(+) 12 | 13 | diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc 14 | index a312ddb..87c9ae2 100644 15 | --- a/OvmfPkg/OvmfPkgX64.dsc 16 | +++ b/OvmfPkg/OvmfPkgX64.dsc 17 | @@ -493,3 +493,5 @@ 18 | } 19 | SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf 20 | !endif 21 | + 22 | + OvmfPkg/Application/MPTest/MPTest.inf 23 | \ No newline at end of file 24 | -- 25 | 2.5.3 26 | 27 | -------------------------------------------------------------------------------- /aos/include/linkage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_LINKAGE_H 10 | #define AOS_LINKAGE_H 11 | 12 | #include 13 | 14 | #ifdef __ASSEMBLY__ 15 | 16 | #ifndef ALIGN 17 | #define ALIGN .align 4,0x90 18 | #define ALIGN_STR ".align 4,0x90" 19 | #endif 20 | 21 | #ifndef ENTRY 22 | #define ENTRY(name) \ 23 | .globl name; \ 24 | ALIGN; \ 25 | name: 26 | #endif 27 | 28 | #ifndef END 29 | #define END(name) \ 30 | .size name, .-name 31 | #endif 32 | 33 | #ifndef ENDPROC 34 | #define ENDPROC(name) \ 35 | .type name, @function; \ 36 | END(name) 37 | #endif 38 | #endif 39 | 40 | #endif /* AOS_LINKAGE_H */ 41 | -------------------------------------------------------------------------------- /xen/ovmf-support/README: -------------------------------------------------------------------------------- 1 | OVMF-on-XEN 2 | =========== 3 | 4 | Here go patches as part of my effort as a Google Summer of Code 5 | mentor for the OVMF-on-XEN project. 6 | 7 | http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=GSOC2011#Enable_Xen_Support_in_OVMF 8 | 9 | The goal is to port UEFI OVMF (UEFI firmware for virtual machines) to run in a 10 | Xen HVM domain. 11 | 12 | Patch ToC 13 | ========= 14 | 15 | ovmf-firmware-unstable-4.2.patch - HVMLOADER changes and binary OVMF images 16 | ovmf-xend-unstable-4.2.patch - XEND changes to support loading different ROM 17 | ovmf-edk2.patch - EDK2 patch against OvmfPkg to support Xen HVM 18 | 19 | Running 20 | ======= 21 | 22 | With XEND patch, your XM config now has the optional hvmbios parameter, which 23 | can be 'rombios', 'ovmf-ia32' and 'ovmf-x64' 24 | 25 | Contact Info 26 | ============ 27 | 28 | Andrei Warkentin (andrey.warkentin@gmail.com, andreiw@vmware.com) -------------------------------------------------------------------------------- /aos/include/asm-arm/system.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_ARM_SYSTEM_H 10 | #define AOS_ARM_SYSTEM_H 11 | 12 | #define PAGE_SIZE (4096) 13 | #define BITS_PER_LONG (32) 14 | 15 | /* 16 | * This is used to ensure the compiler did actually allocate the register we 17 | * asked it for some inline assembly sequences. Apparently we can't trust 18 | * the compiler from one version to another so a bit of paranoia won't hurt. 19 | * This string is meant to be concatenated with the inline asm string and 20 | * will cause compilation to stop on mismatch. 21 | * (for details, see gcc PR 15089) 22 | */ 23 | #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t" 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /linux/3.2/block/dm/0001-DM-Minor-fix-to-dm-snap-metadata-backend-registratio.patch: -------------------------------------------------------------------------------- 1 | From 05e283e519e597134f9d978b745fa93703facb42 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Fri, 24 Feb 2012 21:25:19 -0500 4 | Subject: [PATCH 1/6] DM: Minor fix to dm-snap metadata backend registration. 5 | 6 | Cleanup in dm_exception_store_init was messed up. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | drivers/md/dm-exception-store.c | 2 +- 11 | 1 files changed, 1 insertions(+), 1 deletions(-) 12 | 13 | diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c 14 | index 042e719..aa70f7d 100644 15 | --- a/drivers/md/dm-exception-store.c 16 | +++ b/drivers/md/dm-exception-store.c 17 | @@ -283,7 +283,7 @@ int dm_exception_store_init(void) 18 | return 0; 19 | 20 | persistent_fail: 21 | - dm_persistent_snapshot_exit(); 22 | + dm_transient_snapshot_exit(); 23 | transient_fail: 24 | return r; 25 | } 26 | -- 27 | 1.7.8.3 28 | 29 | -------------------------------------------------------------------------------- /aos/include/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_TYPES_H 10 | #define AOS_TYPES_H 11 | 12 | #include 13 | 14 | typedef unsigned long size_t; 15 | typedef unsigned long ptrdiff_t; 16 | typedef u8 bool; 17 | 18 | #define USHRT_MAX ((u16)(~0U)) 19 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) 20 | #define SHRT_MIN ((s16)(-SHRT_MAX - 1)) 21 | #define INT_MAX ((int)(~0U>>1)) 22 | #define INT_MIN (-INT_MAX - 1) 23 | #define UINT_MAX (~0U) 24 | #define LONG_MAX ((long)(~0UL>>1)) 25 | #define LONG_MIN (-LONG_MAX - 1) 26 | #define ULONG_MAX (~0UL) 27 | #define LLONG_MAX ((long long)(~0ULL>>1)) 28 | #define LLONG_MIN (-LLONG_MAX - 1) 29 | #define ULLONG_MAX (~0ULL) 30 | 31 | #define false (0) 32 | #define true (!false) 33 | #define NULL (0) 34 | 35 | #endif /* AOS_TYPES_H */ 36 | -------------------------------------------------------------------------------- /linux/3.2/block/md/raid1_resync_graveyard/README: -------------------------------------------------------------------------------- 1 | This is a graveyard for interesting, but ultimately unfeasable 2 | ideas w.r.t. improving resync performance by monitoring REQ_DISCARD 3 | requests. 4 | 5 | This patch set against MD and mdadm extends the on-disk bitmap with an 6 | in-use bit, and tracks REQ_DISCARD requests. Unfortunately, it's useless 7 | for bitmap chunk sizes > 4k (because the likelyhood of doing 64m discards is nil). 8 | 9 | 0001-MDADM-Add-support-for-v5-bitmap-with-inuse-bits.patch 10 | 0001-MD-Bitmap-version-cleanup.patch 11 | 0002-MD-RAID1-Optimize-synchronization-to-avoid-blocks-ma.patch 12 | 13 | This patch attempts to improve on above by keeping ranges, and by 14 | removing the on-disk changes (which are unnecessary, due to the way 15 | fstrim and friends are used). However, it suffers from terrible 16 | worst case memory usage - you can't do better than a bit per block, and you're 17 | going to be in a world of pain if someone starts discarding every other 4K. Ex: 18 | 1 MB of RAM to describe 2 MB of "hole punched" disk. 19 | 20 | 0001-MD-RAID1-Optimize-resync-by-avoiding-discarded-block.patch -------------------------------------------------------------------------------- /qemu/0001-qemu-fix-page_check_range.patch: -------------------------------------------------------------------------------- 1 | From 4e6997d998b413b50b6d158b341907726dd3d956 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sat, 22 Mar 2014 01:06:17 -0400 4 | Subject: [PATCH 1/3] qemu: fix page_check_range 5 | 6 | Fixes a segfault. In a case, where signals are delivered 7 | back to back. The second signal causes a segfalt, because 8 | the frame cannot be written to (it was protected beause 9 | the restorer executed from it), but the unprotect 10 | logic exited too early if the checked range exceeded 11 | 1 page. 12 | 13 | Signed-off-by: Andrei Warkentin 14 | --- 15 | translate-all.c | 1 - 16 | 1 files changed, 0 insertions(+), 1 deletions(-) 17 | 18 | diff --git a/translate-all.c b/translate-all.c 19 | index f243c10..5759974 100644 20 | --- a/translate-all.c 21 | +++ b/translate-all.c 22 | @@ -1777,7 +1777,6 @@ int page_check_range(target_ulong start, target_ulong len, int flags) 23 | return -1; 24 | } 25 | } 26 | - return 0; 27 | } 28 | } 29 | return 0; 30 | -- 31 | 1.7.4.1 32 | 33 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0003-Loop-Allow-file-I-O-to-kernel-buffers.patch: -------------------------------------------------------------------------------- 1 | From 49fce318b8cf3ed780fd8f5a6c667071e47d831d Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 10 Aug 2011 15:55:00 -0500 4 | Subject: [PATCH 03/18] Loop: Allow file I/O to kernel buffers. 5 | 6 | flush_dcache_page cannot be called on slab pages. 7 | 8 | Change-Id: I9f002a7f1e40eb4bccaefeef7518afd0e6674c52 9 | Signed-off-by: Andrei Warkentin 10 | --- 11 | drivers/block/loop.c | 5 ++++- 12 | 1 files changed, 4 insertions(+), 1 deletions(-) 13 | 14 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 15 | index 288bbad..2f304a4 100644 16 | --- a/drivers/block/loop.c 17 | +++ b/drivers/block/loop.c 18 | @@ -432,7 +432,10 @@ lo_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf, 19 | size = -EINVAL; 20 | } 21 | 22 | - flush_dcache_page(p->page); 23 | + /* Loop parser can do internal I/O on the file to 24 | + kernel buffers, which have no aliasing issues. */ 25 | + if (!PageSlab(p->page)) 26 | + flush_dcache_page(p->page); 27 | 28 | if (size > 0) 29 | p->offset += size; 30 | -- 31 | 1.7.0.4 32 | 33 | -------------------------------------------------------------------------------- /aos/include/asm-arm/div64.h: -------------------------------------------------------------------------------- 1 | #ifndef AOS_ARM_DIV64 2 | #define AOS_ARM_DIV64 3 | 4 | #include 5 | 6 | /* 7 | * The semantics of do_div() are: 8 | * 9 | * u32 do_div(u64 *n, u32 base) 10 | * { 11 | * u32 remainder = *n % base; 12 | * *n = *n / base; 13 | * return remainder; 14 | * } 15 | * 16 | * In other words, a 64-bit dividend with a 32-bit divisor producing 17 | * a 64-bit result and a 32-bit remainder. To accomplish this optimally 18 | * we call a special __do_div64 helper with completely non standard 19 | * calling convention for arguments and results (beware). 20 | */ 21 | 22 | #define do_div(n, base) \ 23 | ({ \ 24 | register unsigned int __base asm("r4") = base; \ 25 | register unsigned long long __n asm("r0") = n; \ 26 | register unsigned long long __res asm("r2"); \ 27 | register unsigned int __rem asm("r1"); \ 28 | asm( __asmeq("%0", "r1") \ 29 | __asmeq("%1", "r2") \ 30 | __asmeq("%2", "r0") \ 31 | __asmeq("%3", "r4") \ 32 | "bl __do_div64" \ 33 | : "=r" (__rem), "=r" (__res) \ 34 | : "r" (__n), "r" (__base) \ 35 | : "ip", "lr", "cc"); \ 36 | n = __res; \ 37 | __rem; \ 38 | }) 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /linux/3.2/0002-include-log2.h-Fix-rounddown_pow_of_two-1.patch: -------------------------------------------------------------------------------- 1 | From 564ea8f479cb3c62b9cde03690c3429861887b34 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Tue, 8 Nov 2011 14:08:15 -0500 4 | Subject: [PATCH 2/2] include/log2.h: Fix rounddown_pow_of_two(1) 5 | 6 | 1 is a power of two, therefore rounddown_pow_of_two(1) should return 1. It does 7 | in case the argument is a variable but in case it's a constant it behaves 8 | wrong and returns 0. Probably nobody ever did it so this was never noticed, 9 | however net/drivers/vmxnet3 with latest GCC does and breaks on unicpu systems. 10 | 11 | Signed-off-by: Andrei Warkentin 12 | --- 13 | include/linux/log2.h | 2 +- 14 | 1 files changed, 1 insertions(+), 1 deletions(-) 15 | 16 | diff --git a/include/linux/log2.h b/include/linux/log2.h 17 | index 25b8086..ccda848 100644 18 | --- a/include/linux/log2.h 19 | +++ b/include/linux/log2.h 20 | @@ -185,7 +185,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) 21 | #define rounddown_pow_of_two(n) \ 22 | ( \ 23 | __builtin_constant_p(n) ? ( \ 24 | - (n == 1) ? 0 : \ 25 | + (n == 1) ? 1 : \ 26 | (1UL << ilog2(n))) : \ 27 | __rounddown_pow_of_two(n) \ 28 | ) 29 | -- 30 | 1.7.7 31 | 32 | -------------------------------------------------------------------------------- /linux/3.2/block/md/raid1_resync_graveyard/0001-MD-Bitmap-version-cleanup.patch: -------------------------------------------------------------------------------- 1 | From 18dcab2becc91e1440a57fd7cf1b4d35d6d6e3c2 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sun, 15 Jan 2012 02:56:44 -0500 4 | Subject: [PATCH 1/2] MD: Bitmap version cleanup. 5 | 6 | bitmap_new_disk_sb() would still create V3 bitmap superblock 7 | with host-endian layout. 8 | 9 | Signed-off-by: Andrei Warkentin 10 | --- 11 | drivers/md/bitmap.c | 3 --- 12 | drivers/md/bitmap.h | 2 -- 13 | 2 files changed, 0 insertions(+), 5 deletions(-) 14 | 15 | diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c 16 | index 045e086..e786da6 100644 17 | --- a/drivers/md/bitmap.c 18 | +++ b/drivers/md/bitmap.c 19 | @@ -568,9 +568,6 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap) 20 | bitmap->events_cleared = bitmap->mddev->events; 21 | sb->events_cleared = cpu_to_le64(bitmap->mddev->events); 22 | 23 | - bitmap->flags |= BITMAP_HOSTENDIAN; 24 | - sb->version = cpu_to_le32(BITMAP_MAJOR_HOSTENDIAN); 25 | - 26 | kunmap_atomic(sb); 27 | 28 | return 0; 29 | diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h 30 | index a15436d..af588ac 100644 31 | --- a/drivers/md/bitmap.h 32 | +++ b/drivers/md/bitmap.h 33 | @@ -13,8 +13,6 @@ 34 | #define BITMAP_MAJOR_HI 4 35 | #define BITMAP_MAJOR_HOSTENDIAN 3 36 | 37 | -#define BITMAP_MINOR 39 38 | - 39 | /* 40 | * in-memory bitmap: 41 | * 42 | -- 43 | 1.7.8.3 44 | 45 | -------------------------------------------------------------------------------- /qemu/0003-x86-implement-EXCP_TB_EFAULT.patch: -------------------------------------------------------------------------------- 1 | From ae11217e964e53efca79bbaab97b4e7177ed5f1b Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 2 Apr 2014 12:35:04 -0400 4 | Subject: [PATCH 3/3] x86: implement EXCP_TB_EFAULT 5 | 6 | This implements the "TCG would access unmapped memory" 7 | fault for x86_64 and i386. 8 | 9 | See 7258982 for more context. 10 | 11 | Tested using qemu-i386 and sigtest/sigtest_mprotect binaries. 12 | x86_64 has no signal handling implemented, presumably would 13 | work as well. 14 | 15 | Signed-off-by: Andrei Warkentin 16 | --- 17 | linux-user/main.c | 7 +++++++ 18 | 1 files changed, 7 insertions(+), 0 deletions(-) 19 | 20 | diff --git a/linux-user/main.c b/linux-user/main.c 21 | index ebf68b3..3c326c1 100644 22 | --- a/linux-user/main.c 23 | +++ b/linux-user/main.c 24 | @@ -336,6 +336,13 @@ void cpu_loop(CPUX86State *env) 25 | queue_signal(env, info.si_signo, &info); 26 | } 27 | break; 28 | + case EXCP_TB_EFAULT: 29 | + info.si_signo = SIGSEGV; 30 | + info.si_errno = 0; 31 | + info.si_code = TARGET_SEGV_MAPERR; 32 | + info._sifields._sigfault._addr = env->eip; 33 | + queue_signal(env, info.si_signo, &info); 34 | + break; 35 | case EXCP0E_PAGE: 36 | info.si_signo = SIGSEGV; 37 | info.si_errno = 0; 38 | -- 39 | 1.7.4.1 40 | 41 | -------------------------------------------------------------------------------- /linux/2.6.36/android-tegra/0001-Tegra-Lockdepify-clock.c.patch: -------------------------------------------------------------------------------- 1 | From 08299182708a1da8d3ab64f20efb7de039365e5a Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 20 Apr 2011 16:37:25 -0500 4 | Subject: [PATCH 1/2] Tegra: Lockdepify clock.c 5 | 6 | Prevent recursive lock warning. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | arch/arm/mach-tegra/clock.c | 4 ++++ 11 | arch/arm/mach-tegra/clock.h | 1 + 12 | 2 files changed, 5 insertions(+), 0 deletions(-) 13 | 14 | diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c 15 | index 964c4c3..577fe2c 100644 16 | --- a/arch/arm/mach-tegra/clock.c 17 | +++ b/arch/arm/mach-tegra/clock.c 18 | @@ -116,7 +116,11 @@ static inline bool clk_cansleep(struct clk *c) 19 | static inline void clk_lock_init(struct clk *c) 20 | { 21 | mutex_init(&c->mutex); 22 | + lockdep_set_class(&c->mutex, &c->lock_key); 23 | + 24 | spin_lock_init(&c->spinlock); 25 | + lockdep_set_class(&c->spinlock, &c->lock_key); 26 | + 27 | } 28 | 29 | struct clk *tegra_get_clock_by_name(const char *name) 30 | diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h 31 | index f3319d3..764b2c4 100644 32 | --- a/arch/arm/mach-tegra/clock.h 33 | +++ b/arch/arm/mach-tegra/clock.h 34 | @@ -138,6 +138,7 @@ struct clk { 35 | 36 | struct mutex mutex; 37 | spinlock_t spinlock; 38 | + struct lock_class_key lock_key; 39 | }; 40 | 41 | struct clk_duplicate { 42 | -- 43 | 1.7.0.4 44 | 45 | -------------------------------------------------------------------------------- /linux/2.6.36/android-tegra/0002-Tegra-Fix-lockdep-warning-in-cpu-idle.c.patch: -------------------------------------------------------------------------------- 1 | From 5da16301fe132be9a26471e9c4230ceaf38faa75 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 20 Apr 2011 16:38:35 -0500 4 | Subject: [PATCH 2/2] Tegra: Fix lockdep warning in cpu-idle.c. 5 | 6 | Fix inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | arch/arm/mach-tegra/cpuidle.c | 10 ++++++++++ 11 | 1 files changed, 10 insertions(+), 0 deletions(-) 12 | 13 | diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c 14 | index 23cb9ac..38bcc98 100644 15 | --- a/arch/arm/mach-tegra/cpuidle.c 16 | +++ b/arch/arm/mach-tegra/cpuidle.c 17 | @@ -105,14 +105,24 @@ static inline unsigned int time_to_bin(unsigned int time) 18 | 19 | static inline void tegra_unmask_irq(int irq) 20 | { 21 | + struct irq_desc *desc = irq_to_desc(irq); 22 | struct irq_chip *chip = get_irq_chip(irq); 23 | + unsigned long flags; 24 | + 25 | + raw_spin_lock_irqsave(&desc->lock, flags); 26 | chip->unmask(irq); 27 | + raw_spin_unlock_irqrestore(&desc->lock, flags); 28 | } 29 | 30 | static inline void tegra_mask_irq(int irq) 31 | { 32 | + struct irq_desc *desc = irq_to_desc(irq); 33 | struct irq_chip *chip = get_irq_chip(irq); 34 | + unsigned long flags; 35 | + 36 | + raw_spin_lock_irqsave(&desc->lock, flags); 37 | chip->mask(irq); 38 | + raw_spin_unlock_irqrestore(&desc->lock, flags); 39 | } 40 | 41 | static inline int tegra_pending_interrupt(void) 42 | -- 43 | 1.7.0.4 44 | 45 | -------------------------------------------------------------------------------- /linux/3.0/mmc/cmd23/0006-MMC-SDHCI-Auto-CMD23-fixes.patch: -------------------------------------------------------------------------------- 1 | From d8c38570b40d582a1f170217ca456bf71f2cadce Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 25 May 2011 02:05:59 -0500 4 | Subject: [PATCH] MMC: SDHCI Auto-CMD23 fixes. 5 | 6 | Fixes bugs in Auto-CMD23 feature enable decision. Auto-CMD23 7 | shoud be enabled if host is >= v3, and SDMA is not in use. 8 | 9 | USE_ADMA | USE_SDMA | Auto-CMD23 10 | ---------+----------+----------- 11 | 0 | 0 | 1 12 | ---------+----------+----------- 13 | 0 | 1 | 0 14 | ---------+----------+----------- 15 | 1 | 0 | 1 16 | ---------+----------+----------- 17 | 1 | 1 | 1 18 | 19 | Signed-off-by: Andrei Warkentin 20 | --- 21 | drivers/mmc/host/sdhci.c | 4 ++-- 22 | 1 files changed, 2 insertions(+), 2 deletions(-) 23 | 24 | diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c 25 | index fbb1842..a4e64b0 100644 26 | --- a/drivers/mmc/host/sdhci.c 27 | +++ b/drivers/mmc/host/sdhci.c 28 | @@ -2498,9 +2498,9 @@ int sdhci_add_host(struct sdhci_host *host) 29 | host->flags |= SDHCI_AUTO_CMD12; 30 | 31 | /* Auto-CMD23 stuff only works in ADMA or PIO. */ 32 | - if ((host->version == SDHCI_SPEC_300) && 33 | + if ((host->version >= SDHCI_SPEC_300) && 34 | ((host->flags & SDHCI_USE_ADMA) || 35 | - !(host->flags & SDHCI_REQ_USE_DMA))) { 36 | + !(host->flags & SDHCI_USE_SDMA))) { 37 | host->flags |= SDHCI_AUTO_CMD23; 38 | printk(KERN_INFO "%s: Auto-CMD23 available\n", mmc_hostname(mmc)); 39 | } else 40 | -- 41 | 1.7.0.4 42 | 43 | -------------------------------------------------------------------------------- /uefi/DebugPkg/GdbSyms/GdbSyms.inf: -------------------------------------------------------------------------------- 1 | ## @file 2 | # 3 | # Bare-minimum GDB symbols needed for reloading symbols. 4 | # 5 | # This is not a "driver" and should not be placed in a FD. 6 | # 7 | # Copyright (c) 2011, Andrei Warkentin 8 | # 9 | # This program and the accompanying materials 10 | # are licensed and made available under the terms and conditions of the BSD License 11 | # which accompanies this distribution. The full text of the license may be found at 12 | # http://opensource.org/licenses/bsd-license.php 13 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 15 | # 16 | ## 17 | 18 | [Defines] 19 | INF_VERSION = 0x00010005 20 | BASE_NAME = GdbSyms 21 | FILE_GUID = 22abcb60-fb40-42ac-b01f-3ab1fad9aad8 22 | MODULE_TYPE = DXE_DRIVER 23 | VERSION_STRING = 1.0 24 | ENTRY_POINT = Initialize 25 | 26 | # 27 | # The following information is for reference only and not required by the build tools. 28 | # 29 | # VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM 30 | # 31 | 32 | [Sources] 33 | GdbSyms.c 34 | 35 | [Packages] 36 | MdePkg/MdePkg.dec 37 | MdeModulePkg/MdeModulePkg.dec 38 | 39 | [LibraryClasses] 40 | BaseLib 41 | BaseMemoryLib 42 | DebugLib 43 | DxeServicesTableLib 44 | HobLib 45 | MemoryAllocationLib 46 | PcdLib 47 | UefiBootServicesTableLib 48 | UefiDriverEntryPoint 49 | UefiLib 50 | 51 | [Guids] 52 | 53 | [Protocols] 54 | 55 | [Depex] 56 | TRUE 57 | 58 | -------------------------------------------------------------------------------- /aos/lib/ctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | /* 10 | * Copyright (C) 1991, 1992 Linus Torvalds 11 | */ 12 | 13 | #include 14 | 15 | const unsigned char _ctype[] = { 16 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ 17 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ 18 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ 19 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ 20 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ 21 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ 22 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ 23 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ 24 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ 25 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ 26 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ 27 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ 28 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ 29 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ 30 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ 31 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ 32 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ 33 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ 34 | _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */ 35 | _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */ 36 | _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ 37 | _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ 38 | _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ 39 | _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ 40 | -------------------------------------------------------------------------------- /xen/arm/README: -------------------------------------------------------------------------------- 1 | Xen 4.2 ARM port 2 | ================ 3 | 4 | This is a work-in-progress in trying to add ARM support 5 | to latest Xen 4.2-unstable tree. 6 | 7 | This is based off of the Samsung Xen 3.0 tree, which seems 8 | to be a dead project (http://wiki.xensource.com/xenwiki/XenARM) 9 | 10 | Initial support is PV guests on ARMv7 on a Tegra 2 SoC. 11 | 12 | Can't wait for the Cortex A15 ;-). 13 | 14 | Plan of action: 15 | 1) Get all Xen common code building. 16 | 2) Get ARM bootstrap code in and boot to a BUG() 17 | 3) Start filling in missing bits. 18 | 4) ??? (write a book about porting Xen to $FAVORITE_ARCH) 19 | 5) Profit! 20 | 21 | History 22 | ======= 23 | 24 | May 3 2011 25 | ---------- 26 | 27 | Initial commit, starting to clean stuff up. 28 | 29 | 30 | May 4 2011 31 | ---------- 32 | 33 | Added support for platform-specific code to build system, for Tegra 34 | building can be done with - 35 | 36 | XEN_TARGET_PLAT=tegra XEN_TARGET_ARCH=arm CROSS_COMPILE=arm-eabi- make 37 | 38 | ...not that it builds yet. More cleanup. More understanding of what 39 | "public" interfaces are exposed to common code. I shoulds separate 40 | internal stuff from "publics" to make at least other people's lives 41 | a bit easier ;-). Old Xen 3.0 uses DACR to protect kernel from userspace, 42 | probably going to go with a split TTBR0/TTBR1 model instead. 43 | 44 | June 22 2011 45 | ------------ 46 | 47 | At the point where it builds but fails to link. It should be as easy now as 48 | filling in the missing bits, but need to change Xen code to make stuff like 49 | the cpufreq, pci, iommu and other bits optional. 50 | 51 | Contact Info 52 | ============ 53 | 54 | Andrei Warkentin (andrey.warkentin@gmail.com, andreiw@vmware.com) -------------------------------------------------------------------------------- /linux/3.2/olpc/fiq/0004-MMP2-FIQ-debugger-support-for-the-XO-1.75.patch: -------------------------------------------------------------------------------- 1 | From b9596c57b3f69fb60ff9babd161c469289301834 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 28 Sep 2011 19:40:19 -0400 4 | Subject: [PATCH 4/7] MMP2: FIQ debugger support for the XO 1.75. 5 | 6 | This enables the FIQ debugger on UART3 if the FIQ 7 | debugger support is compiled in. 8 | 9 | Signed-off-by: Andrei Warkentin 10 | --- 11 | arch/arm/mach-mmp/olpc-xo-1-75.c | 10 +++++++++- 12 | 1 files changed, 9 insertions(+), 1 deletions(-) 13 | 14 | diff --git a/arch/arm/mach-mmp/olpc-xo-1-75.c b/arch/arm/mach-mmp/olpc-xo-1-75.c 15 | index 7fbdaa5..24f5186 100644 16 | --- a/arch/arm/mach-mmp/olpc-xo-1-75.c 17 | +++ b/arch/arm/mach-mmp/olpc-xo-1-75.c 18 | @@ -529,6 +529,7 @@ static void __init olpc_xo_1_75_init(void) 19 | { 20 | u32 twsi6_lcr; 21 | u32 __iomem *tmp; 22 | + struct clk *debug_clk; 23 | 24 | pm_power_off = olpc_xo_1_75_poweroff; 25 | arm_pm_restart = olpc_xo_1_75_restart; 26 | @@ -538,7 +539,14 @@ static void __init olpc_xo_1_75_init(void) 27 | * an unpopulated (and difficult to install) ribbon cable connector. 28 | * mmp2_add_uart(1); // ttyS0: on the 20-pin jtag/debug connector 29 | */ 30 | - mmp2_add_uart(3); // ttyS2: normal console/debug 31 | + 32 | + debug_clk = clk_get_sys("pxa2xx-uart.2", NULL); 33 | + if (mmp2_fiq_debug_init(0xd4018000, debug_clk, IRQ_MMP2_UART3, 34 | + IRQ_MMP2_IPC, -1)) { 35 | + clk_put(debug_clk); 36 | + mmp2_add_uart(3); // ttyS2: normal console/debug 37 | + } 38 | + 39 | /* 40 | * configure ttyS3 by default, since it might be useful under 41 | * linux. this is okay even if cforth is asked to keep control of 42 | -- 43 | 1.7.6.1 44 | 45 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0005-Loop-Cleanup-parser-matching-logic.patch: -------------------------------------------------------------------------------- 1 | From 529ca27c4c30916d388cb0bee5e6267a5bceaf52 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 10 Aug 2011 16:01:28 -0500 4 | Subject: [PATCH 05/18] Loop: Cleanup parser matching logic. 5 | 6 | No need to play with registering/unregistering raw parser. 7 | 8 | Change-Id: I43df58ca24de4ea49427589839765f316de4446b 9 | Signed-off-by: Andrei Warkentin 10 | --- 11 | drivers/block/loop.c | 9 ++++----- 12 | 1 files changed, 4 insertions(+), 5 deletions(-) 13 | 14 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 15 | index a2f89a0..c511745 100644 16 | --- a/drivers/block/loop.c 17 | +++ b/drivers/block/loop.c 18 | @@ -745,7 +745,10 @@ static int loop_match_parser(struct loop_device *lo, struct file *file) 19 | mutex_unlock(&loop_parsers_mutex); 20 | 21 | /* raw_parser will always bind if no other parsers do. */ 22 | - BUG_ON(!lo->lo_parser); 23 | + if(!lo->lo_parser) { 24 | + lo->lo_parser = &raw_parser; 25 | + lo->lo_parser_priv = lo->lo_parser->init(lo, file); 26 | + } 27 | return 0; 28 | } 29 | 30 | @@ -1775,8 +1778,6 @@ static int __init loop_init(void) 31 | unsigned long range; 32 | struct loop_device *lo, *next; 33 | 34 | - loop_register_parser (&raw_parser); 35 | - 36 | /* 37 | * loop module now has a feature to instantiate underlying device 38 | * structure on-demand, provided that there is an access dev node. 39 | @@ -1850,8 +1851,6 @@ static void __exit loop_exit(void) 40 | 41 | blk_unregister_region(MKDEV(LOOP_MAJOR, 0), range); 42 | unregister_blkdev(LOOP_MAJOR, "loop"); 43 | - 44 | - loop_unregister_parser(&raw_parser); 45 | } 46 | 47 | module_init(loop_init); 48 | -- 49 | 1.7.0.4 50 | 51 | -------------------------------------------------------------------------------- /aos/include/div64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_DIV64_H 10 | #define AOS_DIV64_H 11 | 12 | /* 13 | * Copyright (C) 2003 Bernardo Innocenti 14 | * Based on former asm-ppc/div64.h and asm-m68knommu/div64.h 15 | * 16 | * The semantics of do_div() are: 17 | * 18 | * u32 do_div(u64 *n, u32 base) 19 | * { 20 | * u32 remainder = *n % base; 21 | * *n = *n / base; 22 | * return remainder; 23 | * } 24 | * 25 | * NOTE: macro parameter n is evaluated multiple times, 26 | * beware of side effects! 27 | */ 28 | 29 | #include 30 | 31 | #if BITS_PER_LONG == 64 32 | 33 | # define do_div(n,base) ({ \ 34 | u32 __base = (base); \ 35 | u32 __rem; \ 36 | __rem = ((u64)(n)) % __base; \ 37 | (n) = ((u64)(n)) / __base; \ 38 | __rem; \ 39 | }) 40 | 41 | #elif BITS_PER_LONG == 32 42 | 43 | extern u32 __div64_32(u64 *dividend, u32 divisor); 44 | 45 | /* The unnecessary pointer compare is there 46 | * to check for type safety (n must be 64bit) 47 | */ 48 | # define do_div(n,base) ({ \ 49 | u32 __base = (base); \ 50 | u32 __rem; \ 51 | (void)(((typeof((n)) *)0) == ((u64 *)0)); \ 52 | if (likely(((n) >> 32) == 0)) { \ 53 | __rem = (u32)(n) % __base; \ 54 | (n) = (u32)(n) / __base; \ 55 | } else \ 56 | __rem = __div64_32(&(n), __base); \ 57 | __rem; \ 58 | }) 59 | 60 | #else /* BITS_PER_LONG == ?? */ 61 | 62 | # error do_div() does not yet support the C64 63 | 64 | #endif /* BITS_PER_LONG */ 65 | 66 | #endif /* AOS_DIV64_H */ 67 | -------------------------------------------------------------------------------- /linux/3.2/0001-dev-mem-Fix-wrong-error-on-accessing-beyond-valid-me.patch: -------------------------------------------------------------------------------- 1 | From 0b7ce642a1eea34e9ae3930a053a61948b31bb8f Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 9 Nov 2011 18:31:19 -0500 4 | Subject: [PATCH 1/2] /dev/mem: Fix wrong error on accessing beyond valid 5 | memory addresses. 6 | 7 | Currently this returns -EFAULT, but it really should be returning 0, 8 | as in - 0 bytes read or written. This is what you would get by 9 | opening a block device, seeking to the end, and trying to read 10 | something. Additionally, make lseek() check the sought-to offset 11 | to pass the valid_phys_addr_range test. 12 | 13 | Cc: H. Peter Anvin 14 | Signed-off-by: Andrei Warkentin 15 | --- 16 | drivers/char/mem.c | 9 +++++++-- 17 | 1 files changed, 7 insertions(+), 2 deletions(-) 18 | 19 | diff --git a/drivers/char/mem.c b/drivers/char/mem.c 20 | index 8fc04b4..02d0b1a 100644 21 | --- a/drivers/char/mem.c 22 | +++ b/drivers/char/mem.c 23 | @@ -98,7 +98,7 @@ static ssize_t read_mem(struct file *file, char __user *buf, 24 | char *ptr; 25 | 26 | if (!valid_phys_addr_range(p, count)) 27 | - return -EFAULT; 28 | + return 0; 29 | read = 0; 30 | #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED 31 | /* we don't have page 0 mapped on sparc and m68k.. */ 32 | @@ -156,7 +156,7 @@ static ssize_t write_mem(struct file *file, const char __user *buf, 33 | void *ptr; 34 | 35 | if (!valid_phys_addr_range(p, count)) 36 | - return -EFAULT; 37 | + return 0; 38 | 39 | written = 0; 40 | 41 | @@ -710,6 +710,11 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig) 42 | case SEEK_CUR: 43 | offset += file->f_pos; 44 | case SEEK_SET: 45 | + if (!valid_phys_addr_range(offset, 0)) { 46 | + ret = -EINVAL; 47 | + break; 48 | + } 49 | + 50 | /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */ 51 | if ((unsigned long long)offset >= ~0xFFFULL) { 52 | ret = -EOVERFLOW; 53 | -- 54 | 1.7.7 55 | 56 | -------------------------------------------------------------------------------- /aos/include/lib/ctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_LIB_CTYPE_H 10 | #define AOS_LIB_CTYPE_H 11 | 12 | /* 13 | * NOTE! This ctype does not handle EOF like the standard C 14 | * library is required to. 15 | */ 16 | 17 | #define _U 0x01 /* upper */ 18 | #define _L 0x02 /* lower */ 19 | #define _D 0x04 /* digit */ 20 | #define _C 0x08 /* cntrl */ 21 | #define _P 0x10 /* punct */ 22 | #define _S 0x20 /* white space (space/lf/tab) */ 23 | #define _X 0x40 /* hex digit */ 24 | #define _SP 0x80 /* hard space (0x20) */ 25 | 26 | extern const unsigned char _ctype[]; 27 | 28 | #define __ismask(x) (_ctype[(int)(unsigned char)(x)]) 29 | 30 | #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) 31 | #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) 32 | #define iscntrl(c) ((__ismask(c)&(_C)) != 0) 33 | #define isdigit(c) ((__ismask(c)&(_D)) != 0) 34 | #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) 35 | #define islower(c) ((__ismask(c)&(_L)) != 0) 36 | #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) 37 | #define ispunct(c) ((__ismask(c)&(_P)) != 0) 38 | /* Note: isspace() must return false for %NUL-terminator */ 39 | #define isspace(c) ((__ismask(c)&(_S)) != 0) 40 | #define isupper(c) ((__ismask(c)&(_U)) != 0) 41 | #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) 42 | 43 | #define isascii(c) (((unsigned char)(c))<=0x7f) 44 | #define toascii(c) (((unsigned char)(c))&0x7f) 45 | 46 | static inline unsigned char __tolower(unsigned char c) 47 | { 48 | if (isupper(c)) 49 | c -= 'A'-'a'; 50 | return c; 51 | } 52 | 53 | static inline unsigned char __toupper(unsigned char c) 54 | { 55 | if (islower(c)) 56 | c -= 'a'-'A'; 57 | return c; 58 | } 59 | 60 | #define tolower(c) __tolower(c) 61 | #define toupper(c) __toupper(c) 62 | 63 | #endif /* AOS_LIB_CTYPE_H */ 64 | -------------------------------------------------------------------------------- /qemu/tests/sigtest_mprotect.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define __USE_GNU 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | uint8_t p[4096] __attribute__ ((aligned(4096))); 13 | 14 | void fill_buffer(uint8_t *p) 15 | { 16 | #ifdef __aarch64__ 17 | { 18 | uint32_t *t = (uint32_t *) p; 19 | *t++ = 0xd45c0020; /* hlt #xxxx */ 20 | *t++ = 0xd65f03c0; /* ret */ 21 | } 22 | #elif defined(__x86_64__) || defined(__i386__) 23 | { 24 | uint8_t *t = (uint8_t *) p; 25 | *t++ = 0x0f; 26 | *t++ = 0x0b; /* ud2 */ 27 | *t++ = 0xc3; /* ret */ 28 | } 29 | #endif 30 | } 31 | 32 | void 33 | handler(int signum, siginfo_t *siginfo, void *ctx) 34 | { 35 | ucontext_t *uctx = ctx; 36 | 37 | fprintf(stderr, "got sig %d\n", signum); 38 | 39 | if (signum == SIGILL) { 40 | mprotect(&p, 4096, PROT_NONE); 41 | /* 42 | * Skip the undef instruction and make 43 | * sure we get a back-to-back SIGSEGV. 44 | */ 45 | #ifdef __aarch64__ 46 | uctx->uc_mcontext.pc += 4; 47 | #elif defined(__x86_64__) 48 | uctx->uc_mcontext.gregs[REG_RIP] += 2; 49 | #elif defined(__i386__) 50 | uctx->uc_mcontext.gregs[REG_EIP] += 2; 51 | #else 52 | #error unsupported arch 53 | #endif 54 | } else { 55 | mprotect(&p, 4096, PROT_EXEC); 56 | } 57 | } 58 | 59 | 60 | int 61 | main(int argc, char **argv) 62 | { 63 | static struct sigaction action; 64 | typedef void (*entry_t)(void); 65 | entry_t entry; 66 | 67 | memset(&action, 0, sizeof(action)); 68 | action.sa_sigaction = handler; 69 | sigemptyset(&action.sa_mask); 70 | action.sa_flags = SA_RESTART | SA_SIGINFO; 71 | sigaction(SIGSEGV, &action, NULL); 72 | sigaction(SIGILL, &action, NULL); 73 | 74 | fill_buffer(p); 75 | 76 | if (argc == 1 || strcmp(argv[1], "-2")) { 77 | fprintf(stderr, "SIGSEGV first\n"); 78 | mprotect(&p, 4096, PROT_NONE); 79 | } else { 80 | fprintf(stderr, "SIGILL first\n"); 81 | mprotect(&p, 4096, PROT_EXEC); 82 | } 83 | 84 | entry = (void *) p; 85 | entry(); 86 | fprintf(stderr, "done :)\n"); 87 | return 0; 88 | } 89 | -------------------------------------------------------------------------------- /aos/include/lib/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #ifndef AOS_LIB_STRING_H 10 | #define AOS_LIB_STRING_H 11 | 12 | int strnicmp(const char *s1, const char *s2, size_t len); 13 | int strcasecmp(const char *s1, const char *s2); 14 | int strncasecmp(const char *s1, const char *s2, size_t n); 15 | char *strcpy(char *dest, const char *src); 16 | char *strncpy(char *dest, const char *src, size_t count); 17 | size_t strlcpy(char *dest, const char *src, size_t size); 18 | char *strcat(char *dest, const char *src); 19 | char *strncat(char *dest, const char *src, size_t count); 20 | size_t strlcat(char *dest, const char *src, size_t count); 21 | int strcmp(const char *cs, const char *ct); 22 | int strncmp(const char *cs, const char *ct, size_t count); 23 | char *strchr(const char *s, int c); 24 | char *strrchr(const char *s, int c); 25 | char *strnchr(const char *s, size_t count, int c); 26 | char *skip_spaces(const char *str); 27 | char *strim(char *s); 28 | size_t strlen(const char *s); 29 | size_t strnlen(const char *s, size_t count); 30 | size_t strspn(const char *s, const char *accept); 31 | size_t strcspn(const char *s, const char *reject); 32 | char *strpbrk(const char *cs, const char *ct); 33 | char *strsep(char **s, const char *ct); 34 | void *memset(void *s, int c, size_t count); 35 | void *memcpy(void *dest, const void *src, size_t count); 36 | void *memmove(void *dest, const void *src, size_t count); 37 | int memcmp(const void *cs, const void *ct, size_t count); 38 | void *memscan(void *addr, int c, size_t size); 39 | char *strstr(const char *s1, const char *s2); 40 | char *strnstr(const char *s1, const char *s2, size_t len); 41 | void *memchr(const void *s, int c, size_t n); 42 | 43 | extern const char hex_asc[]; 44 | #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] 45 | #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] 46 | 47 | static inline char *pack_hex_byte(char *buf, u8 byte) 48 | { 49 | *buf++ = hex_asc_hi(byte); 50 | *buf++ = hex_asc_lo(byte); 51 | return buf; 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /uefi/GSoC2012/0004-Compiler-Fixes-to-get-UEFI-building-for-me.patch: -------------------------------------------------------------------------------- 1 | From ad8c2ab12c2274da59347205f846b74d5b1ca3ee Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Fri, 8 Jun 2012 15:15:04 -0400 4 | Subject: [PATCH 4/5] Compiler: Fixes to get UEFI building for me. 5 | 6 | My GCC is too new. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 2 -- 11 | OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c | 2 -- 12 | 2 files changed, 4 deletions(-) 13 | 14 | diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c 15 | index b9034fa..60d9934 100644 16 | --- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c 17 | +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c 18 | @@ -1446,7 +1446,6 @@ IfrMid ( 19 | UINTN Base; 20 | UINTN Length; 21 | CHAR16 *SubString; 22 | - UINT8 *Buffer; 23 | UINT16 BufferLen; 24 | 25 | ZeroMem (Value, sizeof (Value)); 26 | @@ -1502,7 +1501,6 @@ IfrMid ( 27 | 28 | FreePool (String); 29 | } else { 30 | - Buffer = Value[2].Buffer; 31 | BufferLen = Value[2].BufferLen; 32 | 33 | Result->Type = EFI_IFR_TYPE_BUFFER; 34 | diff --git a/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c 35 | index 7138ebf..955ae3d 100644 36 | --- a/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c 37 | +++ b/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c 38 | @@ -236,7 +236,6 @@ BltLibVideoFill ( 39 | ) 40 | { 41 | UINTN DstY; 42 | - VOID *BltMemSrc; 43 | VOID *BltMemDst; 44 | UINTN X; 45 | UINT8 Uint8; 46 | @@ -347,7 +346,6 @@ BltLibVideoFill ( 47 | ); 48 | X = X + MIN (X, Width - X); 49 | } 50 | - BltMemSrc = (VOID *) mBltLibLineBuffer; 51 | LineBufferReady = TRUE; 52 | } 53 | CopyMem (BltMemDst, mBltLibLineBuffer, WidthInBytes); 54 | -- 55 | 2.5.3 56 | 57 | -------------------------------------------------------------------------------- /qemu/tests/sigtest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define __USE_GNU 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | uint8_t p[4096] __attribute__ ((aligned(4096))); 12 | 13 | void fill_buffer(uint8_t *p) 14 | { 15 | #ifdef __aarch64__ 16 | { 17 | uint32_t *t = (uint32_t *) p; 18 | *t++ = 0xd45c0020; /* hlt #xxxx */ 19 | *t++ = 0xd65f03c0; /* ret */ 20 | } 21 | #elif defined(__x86_64__) || defined(__i386__) 22 | { 23 | uint8_t *t = (uint8_t *) p; 24 | *t++ = 0x0f; 25 | *t++ = 0x0b; /* ud2 */ 26 | *t++ = 0xc3; /* ret */ 27 | } 28 | #endif 29 | } 30 | 31 | void 32 | handler(int signum, siginfo_t *siginfo, void *ctx) 33 | { 34 | ucontext_t *uctx = ctx; 35 | 36 | fprintf(stderr, "got sig %d\n", signum); 37 | 38 | if (signum == SIGILL) { 39 | munmap(&p, 4096); 40 | 41 | /* 42 | * Skip the undef instruction and make 43 | * sure we get a back-to-back SIGSEGV. 44 | */ 45 | #ifdef __aarch64__ 46 | uctx->uc_mcontext.pc += 4; 47 | #elif defined(__x86_64__) 48 | uctx->uc_mcontext.gregs[REG_RIP] += 2; 49 | #elif defined(__i386__) 50 | uctx->uc_mcontext.gregs[REG_EIP] += 2; 51 | #else 52 | #error unsupported arch 53 | #endif 54 | } else { 55 | mmap(&p, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 56 | 57 | fill_buffer(p); 58 | 59 | mprotect(&p, 4096, PROT_EXEC); 60 | } 61 | } 62 | 63 | 64 | int 65 | main(int argc, char **argv) 66 | { 67 | static struct sigaction action; 68 | typedef void (*entry_t)(void); 69 | entry_t entry; 70 | 71 | memset(&action, 0, sizeof(action)); 72 | action.sa_sigaction = handler; 73 | sigemptyset(&action.sa_mask); 74 | action.sa_flags = SA_RESTART | SA_SIGINFO;; 75 | sigaction(SIGSEGV, &action, NULL); 76 | sigaction(SIGILL, &action, NULL); 77 | 78 | 79 | if (argc == 1 || strcmp(argv[1], "-2")) { 80 | fprintf(stderr, "SIGSEGV first\n"); 81 | munmap(&p, 4096); 82 | } else { 83 | fprintf(stderr, "SIGILL first\n"); 84 | fill_buffer(p); 85 | mprotect(&p, 4096, PROT_EXEC); 86 | } 87 | 88 | entry = (void *) p; 89 | entry(); 90 | fprintf(stderr, "done :)\n"); 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /uefi/DebugPkg/GdbSyms/GdbSyms.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | 3 | Bare-minimum GDB symbols needed for reloading symbols. 4 | 5 | This is not a "driver" and should not be placed in a FD. 6 | 7 | Copyright (c) 2011, Andrei Warkentin 8 | 9 | This program and the accompanying materials 10 | are licensed and made available under the terms and conditions of the BSD License 11 | which accompanies this distribution. The full text of the license may be found at 12 | http://opensource.org/licenses/bsd-license.php 13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 15 | 16 | **/ 17 | 18 | #include "PiDxe.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | /** 33 | Main entry point. 34 | 35 | @param[in] ImageHandle The firmware allocated handle for the EFI image. 36 | @param[in] SystemTable A pointer to the EFI System Table. 37 | 38 | @retval EFI_SUCCESS Successfully initialized. 39 | 40 | **/ 41 | EFI_STATUS 42 | EFIAPI 43 | Initialize ( 44 | IN EFI_HANDLE ImageHandle, 45 | IN EFI_SYSTEM_TABLE *SystemTable 46 | ) 47 | { 48 | EFI_SYSTEM_TABLE_POINTER ESTP; 49 | EFI_DEBUG_IMAGE_INFO_TABLE_HEADER EDIITH; 50 | EFI_IMAGE_DOS_HEADER EIDH; 51 | EFI_IMAGE_OPTIONAL_HEADER_UNION EIOHU; 52 | EFI_IMAGE_DEBUG_DIRECTORY_ENTRY EIDDE; 53 | EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY EIDCNE; 54 | EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY EIDCRE; 55 | EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY EIDCME; 56 | UINTN Dummy = 57 | (UINTN) &ESTP | 58 | (UINTN) &EDIITH | 59 | (UINTN) &EIDH | 60 | (UINTN) &EIOHU | 61 | (UINTN) &EIDDE | 62 | (UINTN) &EIDCNE | 63 | (UINTN) &EIDCRE | 64 | (UINTN) &EIDCME | 65 | 1 66 | ; 67 | return !!Dummy & EFI_SUCCESS; 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /aos/Rules.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration dependencies. 3 | # 4 | 5 | ifeq ($(debug),y) 6 | verbose := y 7 | frame_pointer := y 8 | else 9 | CFLAGS += -DNDEBUG 10 | endif 11 | 12 | # 13 | # Common. 14 | # 15 | 16 | CFLAGS-y += -g 17 | CFLAGS-y += -I$(BASEDIR)/include 18 | CFLAGS-y += -I$(BASEDIR)/include/asm 19 | CFLAGS-y += -I$(BASEDIR)/include/plat 20 | CFLAGS-$(verbose) += -DVERBOSE 21 | CFLAGS-$(frame_pointer) += -fno-omit-frame-pointer 22 | CFLAGS-y += -MMD -MF .$(@F).d 23 | DEPS = .*.d 24 | CFLAGS += $(CFLAGS-y) 25 | AFLAGS += $(CFLAGS) -D__ASSEMBLY__ 26 | 27 | include $(BASEDIR)/arch/$(ARCH)/Rules.mk 28 | 29 | AS = $(CROSS_COMPILE)as 30 | LD = $(CROSS_COMPILE)ld 31 | CC = $(CROSS_COMPILE)gcc 32 | CPP = $(CC) -E 33 | AR = $(CROSS_COMPILE)ar 34 | RANLIB = $(CROSS_COMPILE)ranlib 35 | NM = $(CROSS_COMPILE)nm 36 | STRIP = $(CROSS_COMPILE)strip 37 | OBJCOPY = $(CROSS_COMPILE)objcopy 38 | OBJDUMP = $(CROSS_COMPILE)objdump 39 | SIZEUTIL = $(CROSS_COMPILE)size 40 | 41 | # 42 | # Ordering here is important. 43 | # 44 | ALL_OBJECTS-y += $(BASEDIR)/arch/$(ARCH)/built_in.o 45 | ALL_OBJECTS-y += $(BASEDIR)/plat/$(PLAT)/built_in.o 46 | ALL_OBJECTS-y += $(BASEDIR)/lib/built_in.o 47 | 48 | include Makefile 49 | 50 | # Ensure each subdirectory has exactly one trailing slash. 51 | subdir-n := $(patsubst %,%/,$(patsubst %/,%,$(subdir-n) $(subdir-))) 52 | subdir-y := $(patsubst %,%/,$(patsubst %/,%,$(subdir-y))) 53 | 54 | # Add explicitly declared subdirectories to the object lists. 55 | OBJECTS-y += $(patsubst %/,%/built_in.o,$(subdir-y)) 56 | 57 | # Add implicitly declared subdirectories (in the object lists) to the 58 | # subdirectory list, and rewrite the object-list entry. 59 | subdir-y += $(filter %/,$(OBJECTS-y)) 60 | OBJECTS-y := $(patsubst %/,%/built-in.o,$(OBJECTS-y)) 61 | 62 | subdir-all := $(subdir-y) $(subdir-n) 63 | 64 | built_in.o: $(OBJECTS-y) 65 | ifeq ($(OBJECTS-y),) 66 | $(CC) $(CFLAGS) -c -x c /dev/null -o $@ 67 | else 68 | $(LD) $(LDFLAGS) -r -o $@ $^ 69 | endif 70 | 71 | %.o: %.c Makefile 72 | $(CC) $(CFLAGS) -c $< -o $@ 73 | 74 | %.o: %.S Makefile 75 | $(CC) $(AFLAGS) -c $< -o $@ 76 | 77 | %.s: %.S Makefile 78 | $(CPP) $(AFLAGS) $< -o $@ 79 | 80 | .PHONY: clean 81 | clean:: $(addprefix _clean_, $(subdir-all)) 82 | rm -f *.o *~ $(DEPS) 83 | _clean_%/: FORCE 84 | $(MAKE) -f $(BASEDIR)/Rules.mk -C $* clean 85 | 86 | -include $(DEPS) -------------------------------------------------------------------------------- /linux/3.2/olpc/fiq/0001-MMP2-Enable-FIQ-support.patch: -------------------------------------------------------------------------------- 1 | From 10872413be161b8fb1361b9b2adca34a5c1d3841 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sat, 24 Sep 2011 03:50:49 -0400 4 | Subject: [PATCH 1/7] MMP2: Enable FIQ support. 5 | 6 | Allows FIQ delivery and FIQ handler support. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | arch/arm/mach-mmp/include/mach/irqs.h | 4 ++++ 11 | arch/arm/mach-mmp/include/mach/mmp2.h | 5 +++++ 12 | arch/arm/mach-mmp/irq-mmp2.c | 18 ++++++++++++++++++ 13 | 3 files changed, 27 insertions(+), 0 deletions(-) 14 | 15 | diff --git a/arch/arm/mach-mmp/include/mach/irqs.h b/arch/arm/mach-mmp/include/mach/irqs.h 16 | index a09d328..dd4545d 100644 17 | --- a/arch/arm/mach-mmp/include/mach/irqs.h 18 | +++ b/arch/arm/mach-mmp/include/mach/irqs.h 19 | @@ -226,4 +226,8 @@ 20 | 21 | #define NR_IRQS (IRQ_BOARD_START) 22 | 23 | +#ifdef CONFIG_FIQ 24 | +#define FIQ_START (0) 25 | +#endif 26 | + 27 | #endif /* __ASM_MACH_IRQS_H */ 28 | diff --git a/arch/arm/mach-mmp/include/mach/mmp2.h b/arch/arm/mach-mmp/include/mach/mmp2.h 29 | index b5f79f2..eb5b57e 100644 30 | --- a/arch/arm/mach-mmp/include/mach/mmp2.h 31 | +++ b/arch/arm/mach-mmp/include/mach/mmp2.h 32 | @@ -10,6 +10,11 @@ extern void __init mmp2_init_icu(void); 33 | extern void __init mmp2_init_irq(void); 34 | extern void mmp2_clear_pmic_int(void); 35 | 36 | +#ifdef CONFIG_FIQ 37 | +extern void icu_fiq_enable(unsigned int irq); 38 | +extern void icu_fiq_disable(unsigned int irq); 39 | +#endif 40 | + 41 | #include 42 | #include 43 | #include 44 | diff --git a/arch/arm/mach-mmp/irq-mmp2.c b/arch/arm/mach-mmp/irq-mmp2.c 45 | index 508689f..0924046 100644 46 | --- a/arch/arm/mach-mmp/irq-mmp2.c 47 | +++ b/arch/arm/mach-mmp/irq-mmp2.c 48 | @@ -20,6 +20,24 @@ 49 | 50 | #include "common.h" 51 | 52 | +#ifdef CONFIG_FIQ 53 | +void icu_fiq_enable(unsigned int irq) 54 | +{ 55 | + uint32_t r = __raw_readl(ICU_INT_CONF(irq)); 56 | + 57 | + r |= ICU_INT_ROUTE_PJ4_FIQ; 58 | + __raw_writel(r, ICU_INT_CONF(irq)); 59 | +} 60 | + 61 | +void icu_fiq_disable(unsigned int irq) 62 | +{ 63 | + uint32_t r = __raw_readl(ICU_INT_CONF(irq)); 64 | + 65 | + r &= ~ICU_INT_ROUTE_PJ4_FIQ; 66 | + __raw_writel(r, ICU_INT_CONF(irq)); 67 | +} 68 | +#endif 69 | + 70 | static void icu_mask_irq(struct irq_data *d) 71 | { 72 | uint32_t r = __raw_readl(ICU_INT_CONF(d->irq)); 73 | -- 74 | 1.7.6.1 75 | 76 | -------------------------------------------------------------------------------- /linux/3.0/mmc/cmd23/0001-MMC-Add-remove-quirks-conditional-support.patch: -------------------------------------------------------------------------------- 1 | From 5cb7673abbb4d758dbf3cf8d374a9dc99ba091f2 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sat, 16 Apr 2011 05:31:47 -0500 4 | Subject: [PATCH 1/5] MMC: Add/remove quirks conditional support. 5 | 6 | Conditional add/remove quirks for MMC and SD. 7 | 8 | Cc: cjb@laptop.org 9 | Cc: malchev@google.com 10 | Signed-off-by: Andrei Warkentin 11 | --- 12 | include/linux/mmc/card.h | 40 ++++++++++++++++++++++++++++++++++++---- 13 | 1 files changed, 36 insertions(+), 4 deletions(-) 14 | 15 | diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h 16 | index 4910dec..7190aa2 100644 17 | --- a/include/linux/mmc/card.h 18 | +++ b/include/linux/mmc/card.h 19 | @@ -273,16 +273,14 @@ struct mmc_fixup { 20 | card->cid.month) 21 | 22 | /* 23 | - * This hook just adds a quirk unconditionally. 24 | + * Unconditionally quirk add/remove. 25 | */ 26 | + 27 | static inline void __maybe_unused add_quirk(struct mmc_card *card, int data) 28 | { 29 | card->quirks |= data; 30 | } 31 | 32 | -/* 33 | - * This hook just removes a quirk unconditionally. 34 | - */ 35 | static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) 36 | { 37 | card->quirks &= ~data; 38 | @@ -308,6 +306,40 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) 39 | #define mmc_sd_card_set_uhs(c) ((c)->state |= MMC_STATE_ULTRAHIGHSPEED) 40 | #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC) 41 | 42 | +/* 43 | + * Quirk add/remove for MMC products. 44 | + */ 45 | + 46 | +static inline void __maybe_unused add_quirk_mmc(struct mmc_card *card, int data) 47 | +{ 48 | + if (mmc_card_mmc(card)) 49 | + card->quirks |= data; 50 | +} 51 | + 52 | +static inline void __maybe_unused remove_quirk_mmc(struct mmc_card *card, 53 | + int data) 54 | +{ 55 | + if (mmc_card_mmc(card)) 56 | + card->quirks &= ~data; 57 | +} 58 | + 59 | +/* 60 | + * Quirk add/remove for SD products. 61 | + */ 62 | + 63 | +static inline void __maybe_unused add_quirk_sd(struct mmc_card *card, int data) 64 | +{ 65 | + if (mmc_card_sd(card)) 66 | + card->quirks |= data; 67 | +} 68 | + 69 | +static inline void __maybe_unused remove_quirk_sd(struct mmc_card *card, 70 | + int data) 71 | +{ 72 | + if (mmc_card_sd(card)) 73 | + card->quirks &= ~data; 74 | +} 75 | + 76 | static inline int mmc_card_lenient_fn0(const struct mmc_card *c) 77 | { 78 | return c->quirks & MMC_QUIRK_LENIENT_FN0; 79 | -- 80 | 1.7.0.4 81 | 82 | -------------------------------------------------------------------------------- /qemu/esxi-arm/0001-Work-arounds-for-running-ESXi-Arm-at-EL2-without-TF-.patch: -------------------------------------------------------------------------------- 1 | From 4bb736e0c9ee5bcb67962bc5ac2ca4590fa81c0d Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sat, 14 Nov 2020 13:32:09 -0800 4 | Subject: [PATCH] Work-arounds for running ESXi-Arm at EL2 without TF-A. 5 | 6 | Signed-off-by: Andrei Warkentin 7 | --- 8 | target/arm/cpu.c | 14 +++++++++----- 9 | target/arm/psci.c | 13 +++++++++++-- 10 | 2 files changed, 20 insertions(+), 7 deletions(-) 11 | 12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c 13 | index 07492e9f9a..d808964ec5 100644 14 | --- a/target/arm/cpu.c 15 | +++ b/target/arm/cpu.c 16 | @@ -1680,11 +1680,15 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) 17 | */ 18 | unset_feature(env, ARM_FEATURE_EL3); 19 | 20 | - /* Disable the security extension feature bits in the processor feature 21 | - * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. 22 | - */ 23 | - cpu->isar.id_pfr1 &= ~0xf0; 24 | - cpu->isar.id_aa64pfr0 &= ~0xf000; 25 | + // 26 | + // AndreiW: allow EL3 checks in OS to pass, to allow it to call SMCs 27 | + // and have those be handled by qemu (UEFI fw has no TF-A) 28 | + // 29 | + // /* Disable the security extension feature bits in the processor feature 30 | + // * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. 31 | + // */ 32 | + // cpu->isar.id_pfr1 &= ~0xf0; 33 | + // cpu->isar.id_aa64pfr0 &= ~0xf000; 34 | } 35 | 36 | if (!cpu->has_el2) { 37 | diff --git a/target/arm/psci.c b/target/arm/psci.c 38 | index 6709e28013..0363a16a6d 100644 39 | --- a/target/arm/psci.c 40 | +++ b/target/arm/psci.c 41 | @@ -71,7 +71,11 @@ bool arm_is_psci_call(ARMCPU *cpu, int excp_type) 42 | case QEMU_PSCI_0_2_FN_MIGRATE: 43 | return true; 44 | default: 45 | - return false; 46 | + // 47 | + // AndreiW: allow any SMCCC call (e.g. SDEI). 48 | + // 49 | + // return false; 50 | + return true; 51 | } 52 | } 53 | 54 | @@ -197,7 +201,12 @@ void arm_handle_psci_call(ARMCPU *cpu) 55 | ret = QEMU_PSCI_RET_NOT_SUPPORTED; 56 | break; 57 | default: 58 | - g_assert_not_reached(); 59 | + // 60 | + // AndreiW: fail any unknown call (e.g. SDEI). 61 | + // 62 | + // g_assert_not_reached(); 63 | + ret = QEMU_PSCI_RET_NOT_SUPPORTED; 64 | + break; 65 | } 66 | 67 | err: 68 | -- 69 | 2.17.1 70 | 71 | -------------------------------------------------------------------------------- /linux/2.6.36/0001-BlueZ-HCI-Be-more-resilient-to-HCI-protocol-problems.patch: -------------------------------------------------------------------------------- 1 | From 1deed8dfc79af7e28492ab2a80dfbe29e20ea803 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sun, 25 Sep 2011 16:45:05 -0400 4 | Subject: [PATCH] BlueZ: HCI: Be more resilient to HCI protocol problems. 5 | 6 | Do not corrupt kernel structs on connect message handling after 7 | a missed (due to HCI transport issues or bad BT controller) 8 | disconnect event message. 9 | 10 | Signed-off-by: Andrei Warkentin 11 | --- 12 | net/bluetooth/hci_event.c | 32 ++++++++++++++++++++++++++------ 13 | 1 files changed, 26 insertions(+), 6 deletions(-) 14 | 15 | diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c 16 | index a40170e..244807d 100644 17 | --- a/net/bluetooth/hci_event.c 18 | +++ b/net/bluetooth/hci_event.c 19 | @@ -1417,8 +1417,15 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s 20 | } else 21 | conn->state = BT_CONNECTED; 22 | 23 | - hci_conn_hold_device(conn); 24 | - hci_conn_add_sysfs(conn); 25 | + /* We could have somehow not hci_conn_del-eted, due 26 | + to errors in the HCI transport. */ 27 | + if (atomic_read(&conn->devref) == 0) { 28 | + hci_conn_hold_device(conn); 29 | + hci_conn_add_sysfs(conn); 30 | + } else { 31 | + BT_ERR("connection to %s was never torn down", batostr(&ev->bdaddr)); 32 | + hci_proto_disconn_cfm(conn, 0x16); 33 | + } 34 | 35 | if (test_bit(HCI_AUTH, &hdev->flags)) 36 | conn->link_mode |= HCI_LM_AUTH; 37 | @@ -2476,8 +2483,16 @@ static inline void hci_sync_conn_complete_evt(struct hci_dev *hdev, struct sk_bu 38 | conn->handle = __le16_to_cpu(ev->handle); 39 | conn->state = BT_CONNECTED; 40 | 41 | - hci_conn_hold_device(conn); 42 | - hci_conn_add_sysfs(conn); 43 | + /* We could have somehow not hci_conn_del-eted, due 44 | + to errors in the HCI transport. */ 45 | + if (atomic_read(&conn->devref) == 0) { 46 | + hci_conn_hold_device(conn); 47 | + hci_conn_add_sysfs(conn); 48 | + } else { 49 | + BT_ERR("sync connection to %s was never torn down", batostr(&ev->bdaddr)); 50 | + hci_proto_disconn_cfm(conn, 0x16); 51 | + } 52 | + 53 | break; 54 | 55 | case 0x11: /* Unsupported Feature or Parameter Value */ 56 | @@ -2823,8 +2838,13 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff 57 | conn->handle = __le16_to_cpu(ev->handle); 58 | conn->state = BT_CONNECTED; 59 | 60 | - hci_conn_hold_device(conn); 61 | - hci_conn_add_sysfs(conn); 62 | + if (atomic_read(&conn->devref) == 0) { 63 | + hci_conn_hold_device(conn); 64 | + hci_conn_add_sysfs(conn); 65 | + } else { 66 | + BT_ERR("le connection to %s was never torn down", batostr(&ev->bdaddr)); 67 | + hci_proto_disconn_cfm(conn, 0x16); 68 | + } 69 | 70 | hci_proto_connect_cfm(conn, ev->status); 71 | 72 | -- 73 | 1.7.6.1 74 | 75 | -------------------------------------------------------------------------------- /linux/3.0/mmc/cmd23/0004-MMC-Block-CMD23-support-for-UHS104-SDXC-cards.patch: -------------------------------------------------------------------------------- 1 | From 0e4c2795ac01184b930056688be2c9d0feaa711d Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 13 Apr 2011 18:08:51 -0500 4 | Subject: [PATCH 4/5] MMC: Block CMD23 support for UHS104/SDXC cards. 5 | 6 | SD cards operating at UHS104 or better support SET_BLOCK_COUNT. 7 | 8 | Cc: arindam.nath@amd.com 9 | Cc: cjb@laptop.org 10 | Cc: arnd@arndb.de 11 | Cc: malchev@google.com 12 | Signed-off-by: Andrei Warkentin 13 | --- 14 | drivers/mmc/card/block.c | 9 ++++++--- 15 | drivers/mmc/core/sd.c | 2 ++ 16 | include/linux/mmc/card.h | 3 +++ 17 | include/linux/mmc/sd.h | 2 +- 18 | 4 files changed, 12 insertions(+), 4 deletions(-) 19 | 20 | diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c 21 | index a380acc..71da564 100755 22 | --- a/drivers/mmc/card/block.c 23 | +++ b/drivers/mmc/card/block.c 24 | @@ -1057,9 +1057,12 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, 25 | blk_queue_logical_block_size(md->queue.queue, 512); 26 | set_capacity(md->disk, size); 27 | 28 | - if (mmc_host_cmd23(card->host) && 29 | - mmc_card_mmc(card)) 30 | - md->flags |= MMC_BLK_CMD23; 31 | + if (mmc_host_cmd23(card->host)) { 32 | + if (mmc_card_mmc(card) || 33 | + (mmc_card_sd(card) && 34 | + card->scr.cmds & SD_SCR_CMD23_SUPPORT)) 35 | + md->flags |= MMC_BLK_CMD23; 36 | + } 37 | 38 | if (mmc_card_mmc(card) && 39 | md->flags & MMC_BLK_CMD23 && 40 | diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c 41 | index 596d0b9..ff27741 100644 42 | --- a/drivers/mmc/core/sd.c 43 | +++ b/drivers/mmc/core/sd.c 44 | @@ -203,6 +203,8 @@ static int mmc_decode_scr(struct mmc_card *card) 45 | else 46 | card->erased_byte = 0x0; 47 | 48 | + if (scr->sda_spec3) 49 | + scr->cmds = UNSTUFF_BITS(resp, 32, 2); 50 | return 0; 51 | } 52 | 53 | diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h 54 | index 4a0e27b..c6927a4 100644 55 | --- a/include/linux/mmc/card.h 56 | +++ b/include/linux/mmc/card.h 57 | @@ -72,6 +72,9 @@ struct sd_scr { 58 | unsigned char bus_widths; 59 | #define SD_SCR_BUS_WIDTH_1 (1<<0) 60 | #define SD_SCR_BUS_WIDTH_4 (1<<2) 61 | + unsigned char cmds; 62 | +#define SD_SCR_CMD20_SUPPORT (1<<0) 63 | +#define SD_SCR_CMD23_SUPPORT (1<<1) 64 | }; 65 | 66 | struct sd_ssr { 67 | diff --git a/include/linux/mmc/sd.h b/include/linux/mmc/sd.h 68 | index c648878..7d35d52 100644 69 | --- a/include/linux/mmc/sd.h 70 | +++ b/include/linux/mmc/sd.h 71 | @@ -66,7 +66,7 @@ 72 | 73 | #define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */ 74 | #define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */ 75 | -#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */ 76 | +#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00-3.0X */ 77 | 78 | /* 79 | * SD bus widths 80 | -- 81 | 1.7.0.4 82 | 83 | -------------------------------------------------------------------------------- /linux/3.2/0001-VMW_PVSCSI-Allow-TCQ-depth-change-through-sysfs.patch: -------------------------------------------------------------------------------- 1 | From 8cd4ea83a557ba90f50740d6058c1d052654c9b7 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Fri, 2 Dec 2011 18:56:00 -0500 4 | Subject: [PATCH] VMW_PVSCSI: Allow TCQ depth change through sysfs. 5 | 6 | Lets pvscsi be like all the other SCSI drivers, with 7 | an adjustable at runtime queue depth. 8 | 9 | Signed-off-by: Andrei Warkentin 10 | --- 11 | drivers/scsi/vmw_pvscsi.c | 39 +++++++++++++++++++++++++++++++++++++++ 12 | 1 files changed, 39 insertions(+), 0 deletions(-) 13 | 14 | diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c 15 | index a18996d..21939ce 100644 16 | --- a/drivers/scsi/vmw_pvscsi.c 17 | +++ b/drivers/scsi/vmw_pvscsi.c 18 | @@ -32,6 +32,7 @@ 19 | #include 20 | #include 21 | #include 22 | +#include 23 | 24 | #include "vmw_pvscsi.h" 25 | 26 | @@ -721,6 +722,43 @@ static int pvscsi_queue_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd 27 | 28 | static DEF_SCSI_QCMD(pvscsi_queue) 29 | 30 | +/** 31 | + * pvscsi_change_queue_depth - setting device queue depth 32 | + * @sdev: scsi device struct 33 | + * @qdepth: requested queue depth 34 | + * @reason: SCSI_QDEPTH_DEFAULT/SCSI_QDEPTH_QFULL/SCSI_QDEPTH_RAMP_UP 35 | + * (see include/scsi/scsi_host.h for definition) 36 | + * 37 | + * Returns queue depth. 38 | + */ 39 | +static int pvscsi_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) 40 | +{ 41 | + int max_depth; 42 | + struct Scsi_Host *shost = sdev->host; 43 | + 44 | + if (reason == SCSI_QDEPTH_DEFAULT || 45 | + reason == SCSI_QDEPTH_RAMP_UP) { 46 | + max_depth = shost->can_queue; 47 | + if (!sdev->tagged_supported) 48 | + max_depth = 1; 49 | + 50 | + if (qdepth > max_depth) 51 | + qdepth = max_depth; 52 | + 53 | + scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); 54 | + } else if (reason == SCSI_QDEPTH_QFULL) 55 | + scsi_track_queue_full(sdev, qdepth); 56 | + 57 | + if (sdev->inquiry_len > 7) 58 | + sdev_printk(KERN_INFO, sdev, "qdepth(%d), tagged(%d), " 59 | + "simple(%d), ordered(%d), scsi_level(%d), cmd_que(%d)\n", 60 | + sdev->queue_depth, sdev->tagged_supported, sdev->simple_tags, 61 | + sdev->ordered_tags, sdev->scsi_level, 62 | + (sdev->inquiry[7] & 2) >> 1); 63 | + 64 | + return sdev->queue_depth; 65 | +} 66 | + 67 | static int pvscsi_abort(struct scsi_cmnd *cmd) 68 | { 69 | struct pvscsi_adapter *adapter = shost_priv(cmd->device->host); 70 | @@ -911,6 +949,7 @@ static struct scsi_host_template pvscsi_template = { 71 | .dma_boundary = UINT_MAX, 72 | .max_sectors = 0xffff, 73 | .use_clustering = ENABLE_CLUSTERING, 74 | + .change_queue_depth = pvscsi_change_queue_depth, 75 | .eh_abort_handler = pvscsi_abort, 76 | .eh_device_reset_handler = pvscsi_device_reset, 77 | .eh_bus_reset_handler = pvscsi_bus_reset, 78 | -- 79 | 1.7.4.1 80 | 81 | -------------------------------------------------------------------------------- /linux/3.2/olpc/fiq/README: -------------------------------------------------------------------------------- 1 | OLPC XO 1.75 FIQ debugger support. 2 | ================================== 3 | 4 | This is a port of the Android FIQ debugger support. 5 | FIQ debugger is useful if system is wedged in an IRQ 6 | storm or otherwise stuck where a KDB/KGDB session is 7 | not going to help. 8 | 9 | FIQ debugger owns a particular serial port. It can 10 | provide a system console (/dev/ttyFIQ0) on that port 11 | as well. 12 | 13 | The FIQ debugger consists of - 14 | 1) Actual FIQ debugger in arch/arm/common/fiq_debugger.c 15 | 2) A platform device providing UART and FIQ control abstractions. 16 | 3) Glue code to enable running normal code in FIQ mode. 17 | 18 | Actual effort is - 19 | 1) Getting the platform device. 20 | 2) Porting FIQ debugger code away from Android and 21 | forward to 3.0. 22 | 3) Changes to the debugger along the way as I see fit. 23 | 24 | Running on the XO 1.75 25 | ====================== 26 | 27 | 1) .config should contain: 28 | CONFIG_MMP2_FIQ_DEBUGGER=y 29 | CONFIG_FIQ_DEBUGGER=y 30 | CONFIG_FIQ_DEBUGGER_CONSOLE=y 31 | CONFIG_FIQ_DEBUGGER_CONSOLE_DEFAULT_ENABLE=y 32 | 33 | For KGDB support also add: 34 | CONFIG_FIQ_DEBUGGER_KGDB_DEFAULT_ENABLE=y 35 | CONFIG_FIQ_DEBUGGER_KGDB_INSECURE=y 36 | CONFIG_FIQ_DEBUGGER_KGDB=y 37 | 38 | Your boot parameters should have a console=ttyFIQ0, 39 | with the UART used corresponding to /dev/ttyS2. 40 | 41 | Port is configured as 115200 8n1 by default. 42 | To change, pass mmp2_fiq_debugger.baud=9600 or 43 | desired baud rate. 44 | 45 | If you send Ctrl-Break you should be greeted by - 46 | debug> 47 | debug> help 48 | FIQ Debugger commands: 49 | pc PC status 50 | regs Register dump 51 | allregs Extended Register dump 52 | bt Stack trace 53 | kmesg Dump dmesg 54 | reboot Reboot 55 | irqs Interupt status 56 | version Kernel version 57 | sleep Allow sleep while in FIQ 58 | nosleep Disable sleep while in FIQ 59 | console Switch terminal to console 60 | cpu Current CPU 61 | cpu Switch to CPU 62 | kgdb Break into or return to KGDB 63 | kgdbon Enable KGDB 64 | kgdboff Disable KGDB 65 | debug> 66 | 67 | Keep in mind that when you're "in the debugger", the system continues 68 | to run normally. It is not "broken in and waiting to continue", but 69 | happily doing what it's doing (or sitting someplace dead waiting to 70 | show you the backtrace). 71 | 72 | That's probably the beauty of the FIQ debugger. 73 | 74 | To-Dos 75 | ====== 76 | 77 | 1) Add KGDB support to FIQ debugger - done! 78 | 2) Rethink/redo the entire sleep/nosleep cycle, especially in the context 79 | of supporting KGDB. 80 | 3) Redo the way commands are dispatched and registered with the FIQ debugger 81 | engine. 82 | 4) Using gdb stubs is hard since Ctrl-Break breaks out of KGDB. Need to 83 | change to Ctrl-Break x 2 for FIQ debugger. 84 | 5) Add a simple gdb mode for "seamless" remote kernel introspection 85 | (and symbol debugging a wedged system, where KDB once again isn't 86 | very useful). 87 | 88 | Contact Info 89 | ============ 90 | 91 | Andrei Warkentin (andrey.warkentin@gmail.com, andreiw@vmware.com) 92 | -------------------------------------------------------------------------------- /xen/ovmf-support/ovmf-xend-unstable-4.2.patch: -------------------------------------------------------------------------------- 1 | # HG changeset patch 2 | # User andreiw@motorola.com 3 | # Date 1304839938 18000 4 | # Node ID c34f2354eec72ba9a4ff6e043df680e11ff185d5 5 | # Parent f728acaed4815b89cf458718cddea538bb2d67d2 6 | Xen: Xend: Expose hvmloader/bios. 7 | 8 | Exposes the hvmloader/bios xenstore key in xend/xm, 9 | so firmware loaded can be overriden (choices: rombios, 10 | ovmf-ia32, ovmf-x64). 11 | 12 | Sign-off-by: Andrei Warkentin 13 | 14 | diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py 15 | --- a/tools/python/xen/xend/XendConfig.py 16 | +++ b/tools/python/xen/xend/XendConfig.py 17 | @@ -153,6 +153,7 @@ 18 | 'fdb': str, 19 | 'keymap': str, 20 | 'isa' : int, 21 | + 'hvmbios' : str, 22 | 'localtime': int, 23 | 'monitor': int, 24 | 'monitor_path': str, 25 | diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py 26 | --- a/tools/python/xen/xend/XendDomainInfo.py 27 | +++ b/tools/python/xen/xend/XendDomainInfo.py 28 | @@ -1789,6 +1789,10 @@ 29 | if self.info.has_key('security_label'): 30 | f('security_label', self.info['security_label']) 31 | 32 | + hvm = self.info.is_hvm() 33 | + if hvm and self.info["platform"].get("hvmbios") is not None: 34 | + f('hvmloader/bios', self.info["platform"].get("hvmbios")) 35 | + 36 | to_store.update(self._vcpuDomDetails()) 37 | 38 | log.debug("Storing domain details: %s", scrub_password(to_store)) 39 | diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py 40 | --- a/tools/python/xen/xm/create.py 41 | +++ b/tools/python/xen/xm/create.py 42 | @@ -168,6 +168,10 @@ 43 | fn=set_value, default=None, 44 | use="Path to kernel image.") 45 | 46 | +gopts.var('hvmbios', val='HVMBIOS', 47 | + fn=set_value, default=None, 48 | + use="Type of firmware to load in HVM mode") 49 | + 50 | gopts.var('ramdisk', val='FILE', 51 | fn=set_value, default='', 52 | use="Path to ramdisk.") 53 | @@ -1084,7 +1088,7 @@ 54 | 'device_model', 'display', 55 | 'fda', 'fdb', 56 | 'gfx_passthru', 'guest_os_type', 57 | - 'hap', 'hpet', 58 | + 'hap', 'hpet', 'hvmbios', 59 | 'isa', 60 | 'keymap', 61 | 'localtime', 62 | @@ -1143,7 +1147,7 @@ 63 | 'on_reboot', 'on_crash', 'features', 'on_xend_start', 64 | 'on_xend_stop', 'target', 'cpuid', 'cpuid_check', 65 | 'machine_address_size', 'suppress_spurious_page_faults', 66 | - 'description']) 67 | + 'description' ]) 68 | 69 | vcpu_conf() 70 | if vals.uuid is not None: 71 | diff --git a/tools/python/xen/xm/xenapi_create.py b/tools/python/xen/xm/xenapi_create.py 72 | --- a/tools/python/xen/xm/xenapi_create.py 73 | +++ b/tools/python/xen/xm/xenapi_create.py 74 | @@ -1090,6 +1090,7 @@ 75 | 'fda', 76 | 'fdb', 77 | 'keymap', 78 | + 'hvmbios', 79 | 'isa', 80 | 'localtime', 81 | 'monitor', 82 | -------------------------------------------------------------------------------- /linux/3.2/kgdb/0003-NETPOLL-Extend-rx_hook-support.patch: -------------------------------------------------------------------------------- 1 | From 8599a6e7931a1fb61ace7b2758011ff613412290 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 22 Feb 2012 15:10:04 -0500 4 | Subject: [PATCH 3/7] NETPOLL: Extend rx_hook support. 5 | 6 | Pass down source information to rx_hook, useful 7 | for accepting connections from unspecified clients. 8 | 9 | Cc: kgdb-bugreport@lists.sourceforge.net 10 | Cc: Jason Wessel 11 | Cc: Matt Mackall 12 | Signed-off-by: Andrei Warkentin 13 | Signed-off-by: Andrei Warkentin 14 | --- 15 | include/linux/netpoll.h | 10 +++++++++- 16 | net/core/netpoll.c | 12 ++++++------ 17 | 2 files changed, 15 insertions(+), 7 deletions(-) 18 | 19 | diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h 20 | index 5dfa091..9a9cfa1 100644 21 | --- a/include/linux/netpoll.h 22 | +++ b/include/linux/netpoll.h 23 | @@ -11,12 +11,19 @@ 24 | #include 25 | #include 26 | #include 27 | +#include 28 | +#include 29 | +#include 30 | 31 | struct netpoll { 32 | struct net_device *dev; 33 | char dev_name[IFNAMSIZ]; 34 | const char *name; 35 | - void (*rx_hook)(struct netpoll *, int, char *, int); 36 | + void (*rx_hook)(struct netpoll *, 37 | + u8 *h_source, 38 | + __be32 saddr, 39 | + struct udphdr *, 40 | + char *, int); 41 | 42 | __be32 local_ip, remote_ip; 43 | u16 local_port, remote_port; 44 | @@ -40,6 +47,7 @@ struct netpoll_info { 45 | struct netpoll *netpoll; 46 | }; 47 | 48 | +void netpoll_poll_dev(struct net_device *dev); 49 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len); 50 | void netpoll_print_options(struct netpoll *np); 51 | int netpoll_parse_options(struct netpoll *np, char *opt); 52 | diff --git a/net/core/netpoll.c b/net/core/netpoll.c 53 | index 3d84fb9..adf6ffd 100644 54 | --- a/net/core/netpoll.c 55 | +++ b/net/core/netpoll.c 56 | @@ -26,8 +26,6 @@ 57 | #include 58 | #include 59 | #include 60 | -#include 61 | -#include 62 | #include 63 | #include 64 | 65 | @@ -189,7 +187,7 @@ static void service_arp_queue(struct netpoll_info *npi) 66 | } 67 | } 68 | 69 | -static void netpoll_poll_dev(struct net_device *dev) 70 | +void netpoll_poll_dev(struct net_device *dev) 71 | { 72 | const struct net_device_ops *ops; 73 | 74 | @@ -221,6 +219,8 @@ static void netpoll_poll_dev(struct net_device *dev) 75 | zap_completion_queue(); 76 | } 77 | 78 | +EXPORT_SYMBOL(netpoll_poll_dev); 79 | + 80 | static void refill_skbs(void) 81 | { 82 | struct sk_buff *skb; 83 | @@ -615,9 +615,9 @@ int __netpoll_rx(struct sk_buff *skb) 84 | if (np->local_port && np->local_port != ntohs(uh->dest)) 85 | continue; 86 | 87 | - np->rx_hook(np, ntohs(uh->source), 88 | - (char *)(uh+1), 89 | - ulen - sizeof(struct udphdr)); 90 | + np->rx_hook(np, eth_hdr(skb)->h_source, 91 | + iph->saddr, uh, (char *)(uh+1), 92 | + ulen - sizeof(struct udphdr)); 93 | hits++; 94 | } 95 | 96 | -- 97 | 1.7.9.2 98 | 99 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0011-Loop-Cleanup-loop-size-computation.patch: -------------------------------------------------------------------------------- 1 | From 7b70b7d198b87accd2ec89076717b4c0c92fa48c Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Thu, 11 Aug 2011 17:08:57 -0500 4 | Subject: [PATCH 11/18] Loop: Cleanup loop size computation. 5 | 6 | Push lo_offset/lo_sizelimit into raw parser size() method, 7 | where it belongs. Get rid of get_loop_size and replace 8 | with read_i_size in loop switch code. Loop switch 9 | code at this point is parser agnostic and does a basic 10 | sanity check in that the two files at least have same 11 | physical size (which is a reasonable check). 12 | 13 | As noted by an earlier comment in loop.h, lo_offset/lo_sizelimit 14 | will only apply to the raw parser and not impact VHD/VMDK/whatnot. 15 | 16 | Change-Id: I8dda29a917e687381f37804054a63d870e48a2d3 17 | Signed-off-by: Andrei Warkentin 18 | --- 19 | drivers/block/loop.c | 36 ++++++++++++++++-------------------- 20 | 1 files changed, 16 insertions(+), 20 deletions(-) 21 | 22 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 23 | index 9d0323a..4593df1 100644 24 | --- a/drivers/block/loop.c 25 | +++ b/drivers/block/loop.c 26 | @@ -184,24 +184,6 @@ static struct loop_func_table *xfer_funcs[MAX_LO_CRYPT] = { 27 | &xor_funcs 28 | }; 29 | 30 | -static loff_t get_loop_size(struct loop_device *lo, struct file *file) 31 | -{ 32 | - loff_t size, offset, loopsize; 33 | - 34 | - /* Compute loopsize in bytes */ 35 | - size = i_size_read(file->f_mapping->host); 36 | - offset = lo->lo_offset; 37 | - loopsize = size - offset; 38 | - if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize) 39 | - loopsize = lo->lo_sizelimit; 40 | - 41 | - /* 42 | - * Unfortunately, if we want to do I/O on the device, 43 | - * the number of 512-byte sectors has to fit into a sector_t. 44 | - */ 45 | - return loopsize >> 9; 46 | -} 47 | - 48 | static int 49 | figure_loop_size(struct loop_device *lo) 50 | { 51 | @@ -887,7 +869,8 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, 52 | This is an extremely basic check. No verification is 53 | done as to whether the new file is supported by the parser 54 | and equivalent in state to the old one. Caveat Emptor! */ 55 | - if (get_loop_size(lo, file) != get_loop_size(lo, old_file)) 56 | + if (i_size_read(file->f_mapping->host) != 57 | + i_size_read(old_file->f_mapping->host)) 58 | goto out_putf; 59 | 60 | /* and ... switch */ 61 | @@ -1818,7 +1801,20 @@ static void raw_release(struct loop_device *lo, struct lo_file *lo_file) 62 | 63 | static loff_t raw_size(struct loop_device *lo, struct lo_file *lo_file) 64 | { 65 | - return get_loop_size(lo, lo_file->file); 66 | + loff_t size, offset, loopsize; 67 | + 68 | + /* Compute loopsize in bytes */ 69 | + size = i_size_read(lo_file->file->f_mapping->host); 70 | + offset = lo->lo_offset; 71 | + loopsize = size - offset; 72 | + if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize) 73 | + loopsize = lo->lo_sizelimit; 74 | + 75 | + /* 76 | + * Unfortunately, if we want to do I/O on the device, 77 | + * the number of 512-byte sectors has to fit into a sector_t. 78 | + */ 79 | + return size >> 9; 80 | } 81 | 82 | static int raw_flush(struct loop_device *lo, struct lo_file *lo_file) 83 | -- 84 | 1.7.0.4 85 | 86 | -------------------------------------------------------------------------------- /linux/3.2/block/md/0001-MD-Allow-restarting-an-interrupted-incremental-recov.patch: -------------------------------------------------------------------------------- 1 | From e67ed99e77c24d86ece9002ff8c4c51df1f9d37d Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 12 Oct 2011 18:58:26 -0400 4 | Subject: [PATCH] MD: Allow restarting an interrupted incremental recovery. 5 | 6 | If an incremental recovery was interrupted, a subsequent 7 | re-add will result in a full recovery, even though an 8 | incremental should be possible (seen with raid1). 9 | 10 | Solve this problem by not updating the superblock on the 11 | recovering device until array is not degraded any longer. 12 | 13 | Cc: Neil Brown 14 | Signed-off-by: Andrei Warkentin 15 | --- 16 | drivers/md/md.c | 19 +++++++++++++------ 17 | drivers/md/md.h | 6 ++++++ 18 | 2 files changed, 19 insertions(+), 6 deletions(-) 19 | 20 | diff --git a/drivers/md/md.c b/drivers/md/md.c 21 | index 5404b22..153b3c6 100644 22 | --- a/drivers/md/md.c 23 | +++ b/drivers/md/md.c 24 | @@ -2444,9 +2444,12 @@ repeat: 25 | continue; /* no noise on spare devices */ 26 | if (test_bit(Faulty, &rdev->flags)) 27 | dprintk("(skipping faulty "); 28 | + else if (test_bit(InIncremental, &rdev->flags)) 29 | + dprintk("(skipping incremental s/r "); 30 | 31 | dprintk("%s ", bdevname(rdev->bdev,b)); 32 | - if (!test_bit(Faulty, &rdev->flags)) { 33 | + if (!test_bit(Faulty, &rdev->flags) && 34 | + !test_bit(InIncremental, &rdev->flags)) { 35 | md_super_write(mddev,rdev, 36 | rdev->sb_start, rdev->sb_size, 37 | rdev->sb_page); 38 | @@ -5490,9 +5493,10 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) 39 | return -EINVAL; 40 | } 41 | 42 | - if (test_bit(In_sync, &rdev->flags)) 43 | + if (test_bit(In_sync, &rdev->flags)) { 44 | rdev->saved_raid_disk = rdev->raid_disk; 45 | - else 46 | + set_bit(InIncremental, &rdev->flags); 47 | + } else 48 | rdev->saved_raid_disk = -1; 49 | 50 | clear_bit(In_sync, &rdev->flags); /* just to be sure */ 51 | @@ -7353,15 +7357,18 @@ static void reap_sync_thread(mddev_t *mddev) 52 | if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && 53 | mddev->pers->finish_reshape) 54 | mddev->pers->finish_reshape(mddev); 55 | - md_update_sb(mddev, 1); 56 | 57 | /* if array is no-longer degraded, then any saved_raid_disk 58 | - * information must be scrapped 59 | + * information must be scrapped, and superblock for 60 | + * incrementally recovered device written out. 61 | */ 62 | if (!mddev->degraded) 63 | - list_for_each_entry(rdev, &mddev->disks, same_set) 64 | + list_for_each_entry(rdev, &mddev->disks, same_set) { 65 | rdev->saved_raid_disk = -1; 66 | + clear_bit(InIncremental, &rdev->flags); 67 | + } 68 | 69 | + md_update_sb(mddev, 1); 70 | clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); 71 | clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); 72 | clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); 73 | diff --git a/drivers/md/md.h b/drivers/md/md.h 74 | index 1e586bb..5e5399a 100644 75 | --- a/drivers/md/md.h 76 | +++ b/drivers/md/md.h 77 | @@ -104,6 +104,12 @@ struct mdk_rdev_s 78 | * accurately as possible is good, but 79 | * not absolutely critical. 80 | */ 81 | +#define InIncremental 12 /* Device is undergoing incremental 82 | + * recovery, hence its superblock 83 | + * is not written out until the recovery 84 | + * ends, allowing the later to be 85 | + * restared if interrupted. 86 | + */ 87 | wait_queue_head_t blocked_wait; 88 | 89 | int desc_nr; /* descriptor index in the superblock */ 90 | -- 91 | 1.7.4.1 92 | 93 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0010-Loop-Implement-parser-I-O-accessor.patch: -------------------------------------------------------------------------------- 1 | From caf8133d1e4a66d42eacf96a5577c290e4f106e0 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Thu, 11 Aug 2011 16:56:23 -0500 4 | Subject: [PATCH 10/18] Loop: Implement parser I/O accessor. 5 | 6 | Implement the direct I/O accessor used by parser code. 7 | 8 | Change-Id: I552eeebc2c818e821d8c4e34810922897ae0eaa0 9 | Signed-off-by: Andrei Warkentin 10 | --- 11 | drivers/block/loop.c | 66 +++++++++++++++++++++++++++++++++++++++++++++---- 12 | 1 files changed, 60 insertions(+), 6 deletions(-) 13 | 14 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 15 | index 29e887c..9d0323a 100644 16 | --- a/drivers/block/loop.c 17 | +++ b/drivers/block/loop.c 18 | @@ -543,6 +543,61 @@ lo_receive(struct loop_device *lo, struct lo_file *lo_file, 19 | return ret; 20 | } 21 | 22 | +static int lo_kbuf_to_bio(struct bio *bio, 23 | + u8 *kbuf, 24 | + size_t len) 25 | +{ 26 | + unsigned int bv_len; 27 | + unsigned int bv_offset; 28 | + struct bio_vec *bvec; 29 | + 30 | + /* Fake a BIO containing bvec's describing a physically 31 | + * contiguous kernel buffer. bio_add_page is too smart 32 | + * and relies on a present rq. In our case, we just want 33 | + * to use the same file I/O logic, which just happens to 34 | + * use BIO. It might be nicer to redo everything to use 35 | + * sg's and convert BIO nvecs to sg inside do_bio_filebacked. 36 | + */ 37 | + while (len) { 38 | + bv_offset = ((uintptr_t) kbuf) & ~PAGE_MASK; 39 | + bv_len = min(len, (unsigned int) PAGE_SIZE - bv_offset); 40 | + bvec = &bio->bi_io_vec[bio->bi_vcnt]; 41 | + bvec->bv_page = virt_to_page(kbuf); 42 | + bvec->bv_len = bv_len; 43 | + bvec->bv_offset = bv_offset; 44 | + bio->bi_vcnt++; 45 | + len -= bv_len; 46 | + kbuf += bv_len; 47 | + } 48 | + return 0; 49 | +} 50 | + 51 | +int loop_parser_io(struct loop_device *lo, 52 | + struct lo_file *lo_file, 53 | + void *kbuf, 54 | + size_t len, 55 | + loff_t pos, 56 | + int cmd) 57 | +{ 58 | + int ret; 59 | + unsigned nr_vecs = (len + PAGE_SIZE -1) >> PAGE_SHIFT; 60 | + struct bio *bio = bio_alloc(GFP_KERNEL, nr_vecs); 61 | + 62 | + ret = lo_kbuf_to_bio(bio, (u8 *) kbuf, len); 63 | + if (ret) 64 | + goto out; 65 | + 66 | + if (cmd == READ) 67 | + ret = lo_receive(lo, lo_file, bio, pos, true); 68 | + else 69 | + ret = lo_send(lo, lo_file, bio, pos, true); 70 | +out: 71 | + bio_put(bio); 72 | + return ret; 73 | +} 74 | + 75 | +EXPORT_SYMBOL(loop_parser_io); 76 | + 77 | static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) 78 | { 79 | int ret; 80 | @@ -928,6 +983,10 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode, 81 | mapping_set_gfp_mask(mapping, 82 | lo->lo_file.old_gfp_mask & ~(__GFP_IO|__GFP_FS)); 83 | 84 | + lo->lo_flags = lo_flags; 85 | + lo->transfer = transfer_none; 86 | + lo->lo_sizelimit = 0; 87 | + 88 | error = loop_match_parser(lo, &lo->lo_file); 89 | if (error) 90 | goto out_putlf; 91 | @@ -941,14 +1000,9 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode, 92 | if (!(mode & FMODE_WRITE)) 93 | lo_flags |= LO_FLAGS_READ_ONLY; 94 | 95 | - set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0); 96 | - 97 | lo->lo_device = bdev; 98 | - lo->lo_flags = lo_flags; 99 | - lo->transfer = transfer_none; 100 | lo->ioctl = NULL; 101 | - lo->lo_sizelimit = 0; 102 | - 103 | + set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0); 104 | bio_list_init(&lo->lo_bio_list); 105 | 106 | /* 107 | -- 108 | 1.7.0.4 109 | 110 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0012-Loop-Allow-parser-to-notify-loop-if-losetup-should-f.patch: -------------------------------------------------------------------------------- 1 | From d1d8bbc122594805a7f0e6b3cb7f674b80c31b99 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Fri, 12 Aug 2011 14:59:09 -0500 4 | Subject: [PATCH 12/18] Loop: Allow parser to notify loop if losetup should fail. 5 | 6 | This let's us deal with corrupt files, as you wouldn't 7 | want to allow raw access to them anyway. 8 | 9 | Also adds a 'name' field to lo_parser. 10 | 11 | Change-Id: I67402d9e79ec558ebe46dca79b715c36fa537a3c 12 | Signed-off-by: Andrei Warkentin 13 | --- 14 | drivers/block/loop.c | 19 ++++++++++++++----- 15 | include/linux/loop.h | 8 ++++++++ 16 | 2 files changed, 22 insertions(+), 5 deletions(-) 17 | 18 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 19 | index 4593df1..31d50e7 100644 20 | --- a/drivers/block/loop.c 21 | +++ b/drivers/block/loop.c 22 | @@ -562,7 +562,7 @@ int loop_parser_io(struct loop_device *lo, 23 | int cmd) 24 | { 25 | int ret; 26 | - unsigned nr_vecs = (len + PAGE_SIZE -1) >> PAGE_SHIFT; 27 | + unsigned nr_vecs = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; 28 | struct bio *bio = bio_alloc(GFP_KERNEL, nr_vecs); 29 | 30 | ret = lo_kbuf_to_bio(bio, (u8 *) kbuf, len); 31 | @@ -810,15 +810,22 @@ static int loop_match_parser(struct loop_device *lo, struct lo_file *lo_file) 32 | } 33 | 34 | module_put(owner); 35 | + 36 | + if (ret == -EPERM) 37 | + break; 38 | } 39 | mutex_unlock(&loop_parsers_mutex); 40 | 41 | - /* raw_parser will always bind if no other parsers do. */ 42 | - if(!lo->lo_parser) { 43 | + /* 44 | + * raw_parser will always bind if no other parsers do, 45 | + * unless a parser noted that the file is supported, but 46 | + * losetup should be denied. 47 | + */ 48 | + if(!lo->lo_parser && ret != -EPERM) { 49 | lo->lo_parser = &raw_parser; 50 | lo->lo_parser->init(lo, lo_file); 51 | } 52 | - return 0; 53 | + return ret; 54 | } 55 | 56 | static void loop_release_parser(struct loop_device *lo) 57 | @@ -1647,7 +1654,8 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); 58 | 59 | int loop_register_parser(struct loop_parser *parser) 60 | { 61 | - if (!parser->init || 62 | + if (!parser->name || 63 | + !parser->init || 64 | !parser->release || 65 | !parser->flush || 66 | !parser->size || 67 | @@ -1824,6 +1832,7 @@ static int raw_flush(struct loop_device *lo, struct lo_file *lo_file) 68 | 69 | static struct loop_parser raw_parser = 70 | { 71 | + .name = "raw", 72 | .init = raw_init, 73 | .release = raw_release, 74 | .flush = raw_flush, 75 | diff --git a/include/linux/loop.h b/include/linux/loop.h 76 | index c2a2070..8f5a8af 100644 77 | --- a/include/linux/loop.h 78 | +++ b/include/linux/loop.h 79 | @@ -176,6 +176,7 @@ typedef struct bio_vec *(*loop_xform)( 80 | /* Support for loadable parser modules */ 81 | struct loop_parser { 82 | struct list_head list; 83 | + const char *name; 84 | int (*init)(struct loop_device *lo, struct lo_file *lo_file); 85 | void (*release)(struct loop_device *lo, struct lo_file *lo_file); 86 | int (*flush)(struct loop_device *lo, struct lo_file *lo_file); 87 | @@ -186,6 +187,13 @@ struct loop_parser { 88 | 89 | int loop_register_parser(struct loop_parser *parser); 90 | int loop_unregister_parser(struct loop_parser *parser); 91 | +int loop_parser_io(struct loop_device *lo, 92 | + struct lo_file *lo_file, 93 | + void *kbuf, 94 | + size_t len, 95 | + loff_t pos, 96 | + int cmd); 97 | + 98 | #endif 99 | /* 100 | * IOCTL commands --- we will commandeer 0x4C ('L') 101 | -- 102 | 1.7.0.4 103 | 104 | -------------------------------------------------------------------------------- /aos/arch/arm/entry.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Andrei Warkentin 3 | * 4 | * This program is free software ; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | */ 8 | 9 | #define DebugUartBase 0x70006040 10 | #define CpuVectorBaseAddress 0x0 11 | 12 | .globl _aos_entry 13 | 14 | .macro dputc,val 15 | mov r0, \val 16 | bl putc 17 | .endm 18 | 19 | .section ".start", #alloc, #execinstr 20 | .align 21 | _aos_entry: 22 | .text 23 | .type _aos_entry, #function 24 | .rept 8 25 | mov r0, r0 26 | .endr 27 | 28 | b 1f 29 | .word 0x016f2818 @ Magic numbers to help the loader 30 | .word _aos_entry 31 | .word _end 32 | 1: 33 | mov ip, r2 @ Save ATAG pointer. 34 | dputc #'0' 35 | 36 | @ Enable Strict alignment checking & Instruction cache. 37 | mrc p15, 0, r0, c1, c0, 0 38 | bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) 39 | bic r0, r0, #0x00000005 @ clear bits 0, 2 (---- -C-M) 40 | orr r0, r0, #0x00000002 @ set bit 1 (A) Align 41 | orr r0, r0, #0x00001000 @ set bit 12 (I) enable I-Cache 42 | mcr p15, 0, r0, c1, c0, 0 43 | dputc #'1' 44 | 45 | @ Enable NEON register in case folks want to use them for optimizations (CopyMem) 46 | mrc p15, 0, r0, c1, c0, 2 47 | orr r0, r0, #0x00f00000 @ Enable VFP access (V* instructions) 48 | mcr p15, 0, r0, c1, c0, 2 49 | mov r0, #0x40000000 @ Set EN bit in FPEXC 50 | mcr p10,#0x7,r0,c8,c0,#0 51 | dputc #'2' 52 | 53 | @ Set CPU vectors. 54 | adr r0, vectors 55 | adr r1, vectors_end 56 | ldr r2, =CpuVectorBaseAddress 57 | mcr p15, 0, r2, c12, c0, 0 58 | 1: ldr r3, [r0], #4 59 | str r3, [r2], #4 60 | cmp r0, r1 61 | blo 1b 62 | isb 63 | dputc #'3' 64 | 65 | @ Load stack and fix-up GOT. 66 | adr r0, LC0 67 | ldmia r0, {r1, r2, r3, sp} 68 | subs r0, r0, r1 @ r0 = actual - linked 69 | add r2, r2, r0 70 | add r3, r3, r0 71 | add sp, sp, r0 72 | 73 | 1: ldr r6, [r2], #0 74 | add r6, r6, r0 @ actual = linked + r0 75 | str r6, [r2], #4 76 | cmp r2, r3 77 | blo 1b 78 | dputc #'4' 79 | dputc #'\n' 80 | dputc #'\r' 81 | 82 | mov r0, ip @ ATAG pointer. 83 | blx c_entry 84 | b dead_loop 85 | 86 | @ We are manually relocating this down to VectorsBase. 87 | vectors: 88 | b dead_loop @ RESET, never taken since it always goes to 0x0 89 | b und_vector @ UND 90 | b swi_vector @ SWI 91 | b pabt_vector @ PABT 92 | b dabt_vector @ DABT 93 | b unk_vector @ ? 94 | b irq_vector @ IRQ 95 | b fiq_vector @ FIQ 96 | und_vector: 97 | dputc #'U' 98 | b dead_loop 99 | swi_vector: 100 | dputc #'S' 101 | b dead_loop 102 | pabt_vector: 103 | dputc #'P' 104 | b dead_loop 105 | dabt_vector: 106 | dputc #'D' 107 | b dead_loop 108 | unk_vector: 109 | dputc #'?' 110 | b dead_loop 111 | irq_vector: 112 | dputc #'I' 113 | b dead_loop 114 | fiq_vector: 115 | dputc #'F' 116 | b dead_loop 117 | dead_loop: 118 | dputc #'D' 119 | dputc #'E' 120 | dputc #'A' 121 | dputc #'D' 122 | dputc #'\n' 123 | dputc #'\r' 124 | 1: b 1b 125 | 126 | putc: 127 | ldr r1, =DebugUartBase 128 | cmp r1, #0 129 | beq 1f 130 | strb r0, [r1] 131 | 1: mov pc, lr 132 | vectors_end: 133 | 134 | .ltorg 135 | 136 | .align 2 137 | .type LC0, #object 138 | LC0: 139 | .word LC0 @ r1 140 | .word _got_start @ r2 141 | .word _got_end @ r3 142 | .word _stack_end @ sp 143 | .align 144 | 145 | .section ".bss" 146 | .align 2 147 | _stack: .space 4096 148 | _stack_end: -------------------------------------------------------------------------------- /git/0001-Git-p4-Add-git-p4-change-command.patch: -------------------------------------------------------------------------------- 1 | From 8402ca9b942fa5e869ff9c9529e4bc8095e806c1 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Fri, 14 Oct 2011 17:46:04 -0400 4 | Subject: [PATCH] Git-p4: Add "git p4 change" command. 5 | 6 | Many users of p4/sd use changelists for review, regression 7 | tests and batch builds. 8 | 9 | "p4 change" is almost equivalent to "p4 submit", yet will 10 | just create the changelist and not submit it. 11 | 12 | Signed-off-by: Andrei Warkentin 13 | --- 14 | contrib/fast-import/git-p4 | 23 ++++++++++++++++++----- 15 | 1 files changed, 18 insertions(+), 5 deletions(-) 16 | 17 | diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4 18 | index 2f7b270..dd084b9 100755 19 | --- a/contrib/fast-import/git-p4 20 | +++ b/contrib/fast-import/git-p4 21 | @@ -950,7 +950,10 @@ class P4Submit(Command, P4UserMap): 22 | if checkModTime and (os.stat(fileName).st_mtime <= mtime): 23 | response = "x" 24 | while response != "y" and response != "n": 25 | - response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ") 26 | + if (self.cmdname == "change"): 27 | + response = raw_input("Change template unchanged. Create changelist anyway? [y]es, [n]o (skip this patch) ") 28 | + else: 29 | + response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ") 30 | 31 | if response == "y": 32 | tmpFile = open(fileName, "rb") 33 | @@ -959,7 +962,10 @@ class P4Submit(Command, P4UserMap): 34 | submitTemplate = message[:message.index(separatorLine)] 35 | if self.isWindows: 36 | submitTemplate = submitTemplate.replace("\r\n", "\n") 37 | - p4_write_pipe("submit -i", submitTemplate) 38 | + if (self.cmdname == "change"): 39 | + p4_write_pipe("change -i", submitTemplate) 40 | + else: 41 | + p4_write_pipe("submit -i", submitTemplate) 42 | 43 | if self.preserveUser: 44 | if p4User: 45 | @@ -981,9 +987,14 @@ class P4Submit(Command, P4UserMap): 46 | file = open(fileName, "w+") 47 | file.write(self.prepareLogMessage(template, logMessage)) 48 | file.close() 49 | - print ("Perforce submit template written as %s. " 50 | - + "Please review/edit and then use p4 submit -i < %s to submit directly!" 51 | - % (fileName, fileName)) 52 | + if (self.cmdname == "change"): 53 | + print ("Perforce change template written as %s. " 54 | + + "Please review/edit and then use p4 change -i < %s to submit directly!" 55 | + % (fileName, fileName)) 56 | + else: 57 | + print ("Perforce submit template written as %s. " 58 | + + "Please review/edit and then use p4 submit -i < %s to submit directly!" 59 | + % (fileName, fileName)) 60 | 61 | def run(self, args): 62 | if len(args) == 0: 63 | @@ -2177,6 +2188,7 @@ commands = { 64 | "debug" : P4Debug, 65 | "submit" : P4Submit, 66 | "commit" : P4Submit, 67 | + "change" : P4Submit, 68 | "sync" : P4Sync, 69 | "rebase" : P4Rebase, 70 | "clone" : P4Clone, 71 | @@ -2202,6 +2214,7 @@ def main(): 72 | sys.exit(2) 73 | 74 | options = cmd.options 75 | + cmd.cmdname = cmdName 76 | cmd.gitdir = os.environ.get("GIT_DIR", None) 77 | 78 | args = sys.argv[2:] 79 | -- 80 | 1.7.4.1 81 | 82 | -------------------------------------------------------------------------------- /linux/3.2/pe32+/hello.asm: -------------------------------------------------------------------------------- 1 | BITS 64 2 | 3 | ;; 4 | ;; Modified from one of the Tiny-PE examples. 5 | ;; 6 | 7 | ;; 8 | ;; MZ header 9 | ;; 10 | ;; The only two fields that matter are e_magic and e_lfanew 11 | 12 | mzhdr: 13 | dw "MZ" ; e_magic 14 | dw 0 ; e_cblp UNUSED 15 | dw 0 ; e_cp UNUSED 16 | dw 0 ; e_crlc UNUSED 17 | dw 0 ; e_cparhdr UNUSED 18 | dw 0 ; e_minalloc UNUSED 19 | dw 0 ; e_maxalloc UNUSED 20 | dw 0 ; e_ss UNUSED 21 | dw 0 ; e_sp UNUSED 22 | dw 0 ; e_csum UNUSED 23 | dw 0 ; e_ip UNUSED 24 | dw 0 ; e_cs UNUSED 25 | dw 0 ; e_lsarlc UNUSED 26 | dw 0 ; e_ovno UNUSED 27 | times 4 dw 0 ; e_res UNUSED 28 | dw 0 ; e_oemid UNUSED 29 | dw 0 ; e_oeminfo UNUSED 30 | times 10 dw 0 ; e_res2 UNUSED 31 | dd pesig ; e_lfanew 32 | 33 | ;; 34 | ;; PE signature 35 | ;; 36 | 37 | pesig: 38 | dd "PE" 39 | 40 | ;; 41 | ;; PE header 42 | ;; 43 | 44 | pehdr: 45 | dw 0x8664 ; Machine (AMD64) 46 | dw 1 ; NumberOfSections 47 | dd 0x4545BE5D ; TimeDateStamp UNUSED 48 | dd 0 ; PointerToSymbolTable UNUSED 49 | dd 0 ; NumberOfSymbols UNUSED 50 | dw opthdrsize ; SizeOfOptionalHeader 51 | dw 0x3 ; Characteristics (no relocations, executable) 52 | 53 | ;; 54 | ;; PE optional header 55 | ;; 56 | 57 | filealign equ 1 58 | sectalign equ 1 59 | 60 | %define round(n, r) (((n+(r-1))/r)*r) 61 | 62 | opthdr: 63 | dw 0x20B ; Magic (PE32+) 64 | db 8 ; MajorLinkerVersion UNUSED 65 | db 0 ; MinorLinkerVersion UNUSED 66 | dd round(codesize, filealign) ; SizeOfCode UNUSED 67 | dd 0 ; SizeOfInitializedData UNUSED 68 | dd 0 ; SizeOfUninitializedData UNUSED 69 | dd start ; AddressOfEntryPoint 70 | dd code ; BaseOfCode UNUSED 71 | 72 | dq 0x400000 ; ImageBase 73 | dd sectalign ; SectionAlignment 74 | dd filealign ; FileAlignment 75 | dw 4 ; MajorOperatingSystemVersion UNUSED 76 | dw 0 ; MinorOperatingSystemVersion UNUSED 77 | dw 0 ; MajorImageVersion UNUSED 78 | dw 0 ; MinorImageVersion UNUSED 79 | dw 4 ; MajorSubsystemVersion 80 | dw 0 ; MinorSubsystemVersion UNUSED 81 | dd 0 ; Win32VersionValue UNUSED 82 | dd round(filesize, sectalign) ; SizeOfImage 83 | dd round(hdrsize, filealign) ; SizeOfHeaders 84 | dd 0 ; CheckSum UNUSED 85 | dw 0 ; Subsystem (Unknown) 86 | dw 0x400 ; DllCharacteristics UNUSED 87 | dq 0x100000 ; SizeOfStackReserve UNUSED 88 | dq 0x1000 ; SizeOfStackCommit 89 | dq 0x100000 ; SizeOfHeapReserve 90 | dq 0x1000 ; SizeOfHeapCommit UNUSED 91 | dd 0 ; LoaderFlags UNUSED 92 | dd 16 ; NumberOfRvaAndSizes UNUSED 93 | 94 | ;; 95 | ;; Data directories 96 | ;; 97 | 98 | times 16 dd 0, 0 99 | 100 | opthdrsize equ $ - opthdr 101 | 102 | ;; 103 | ;; PE code section 104 | ;; 105 | 106 | db ".text", 0, 0, 0 ; Name 107 | dd codesize ; VirtualSize 108 | dd round(hdrsize, sectalign) ; VirtualAddress 109 | dd round(codesize, filealign) ; SizeOfRawData 110 | dd code ; PointerToRawData 111 | dd 0 ; PointerToRelocations UNUSED 112 | dd 0 ; PointerToLinenumbers UNUSED 113 | dw 0 ; NumberOfRelocations UNUSED 114 | dw 0 ; NumberOfLinenumbers UNUSED 115 | dd 0x60000020 ; Characteristics (code, execute, read) UNUSED 116 | 117 | hdrsize equ $ - $$ 118 | 119 | ;; 120 | ;; PE code section data 121 | ;; 122 | 123 | align filealign, db 0 124 | 125 | code: 126 | 127 | ;; Entry point 128 | 129 | start: lea rsi, [rip + string - next] 130 | next: mov rdi, 1 131 | mov rax, 1 132 | mov rdx, 26 133 | syscall 134 | 135 | mov rdi,11 136 | mov rax,0x3c 137 | syscall 138 | string db "Hello Linux from PE-32+!",10,0 139 | 140 | codesize equ $ - code 141 | filesize equ $ - $$ 142 | -------------------------------------------------------------------------------- /linux/3.0/mmc/cmd23/0005-MMC-SDHCI-AutoCMD23-support.patch: -------------------------------------------------------------------------------- 1 | From 0821f0e989036b4ffdad540e85e7420a87b282a8 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sat, 16 Apr 2011 04:32:42 -0500 4 | Subject: [PATCH 5/5] MMC: SDHCI AutoCMD23 support. 5 | 6 | Enables Auto-CMD23 support where available (SDHCI 3.0 controllers) 7 | 8 | Cc: arindam.nath@amd.com 9 | Cc: cjb@laptop.org 10 | Cc: arnd@arndb.de 11 | Cc: subhashj@codeaurora.org 12 | Cc: malchev@google.com 13 | Tested-by: Arindam Nath 14 | Signed-off-by: Andrei Warkentin 15 | --- 16 | drivers/mmc/host/sdhci.c | 17 ++++++++++++++++- 17 | drivers/mmc/host/sdhci.h | 2 ++ 18 | include/linux/mmc/sdhci.h | 1 + 19 | 3 files changed, 19 insertions(+), 1 deletions(-) 20 | 21 | diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c 22 | index 3a53512..fbb1842 100644 23 | --- a/drivers/mmc/host/sdhci.c 24 | +++ b/drivers/mmc/host/sdhci.c 25 | @@ -860,7 +860,13 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host, 26 | if (!host->mrq->sbc && 27 | host->flags & SDHCI_AUTO_CMD12) 28 | mode |= SDHCI_TRNS_AUTO_CMD12; 29 | + else if (host->mrq->sbc && 30 | + host->flags & SDHCI_AUTO_CMD23) { 31 | + mode |= SDHCI_TRNS_AUTO_CMD23; 32 | + sdhci_writel(host, host->mrq->sbc->arg, SDHCI_ARGUMENT2); 33 | + } 34 | } 35 | + 36 | if (data->flags & MMC_DATA_READ) 37 | mode |= SDHCI_TRNS_READ; 38 | if (host->flags & SDHCI_REQ_USE_DMA) 39 | @@ -1255,7 +1261,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) 40 | host->mrq = mrq; 41 | } 42 | 43 | - if (mrq->sbc) 44 | + if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23)) 45 | sdhci_send_command(host, mrq->sbc); 46 | else 47 | sdhci_send_command(host, mrq->cmd); 48 | @@ -2491,6 +2497,15 @@ int sdhci_add_host(struct sdhci_host *host) 49 | if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12) 50 | host->flags |= SDHCI_AUTO_CMD12; 51 | 52 | + /* Auto-CMD23 stuff only works in ADMA or PIO. */ 53 | + if ((host->version == SDHCI_SPEC_300) && 54 | + ((host->flags & SDHCI_USE_ADMA) || 55 | + !(host->flags & SDHCI_REQ_USE_DMA))) { 56 | + host->flags |= SDHCI_AUTO_CMD23; 57 | + printk(KERN_INFO "%s: Auto-CMD23 available\n", mmc_hostname(mmc)); 58 | + } else 59 | + printk(KERN_INFO "%s: Auto-CMD23 unavailable\n", mmc_hostname(mmc)); 60 | + 61 | /* 62 | * A controller may support 8-bit width, but the board itself 63 | * might not have the pins brought out. Boards that support 64 | diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h 65 | index 2c3fbc5..745c42f 100644 66 | --- a/drivers/mmc/host/sdhci.h 67 | +++ b/drivers/mmc/host/sdhci.h 68 | @@ -25,6 +25,7 @@ 69 | */ 70 | 71 | #define SDHCI_DMA_ADDRESS 0x00 72 | +#define SDHCI_ARGUMENT2 SDHCI_DMA_ADDRESS 73 | 74 | #define SDHCI_BLOCK_SIZE 0x04 75 | #define SDHCI_MAKE_BLKSZ(dma, blksz) (((dma & 0x7) << 12) | (blksz & 0xFFF)) 76 | @@ -37,6 +38,7 @@ 77 | #define SDHCI_TRNS_DMA 0x01 78 | #define SDHCI_TRNS_BLK_CNT_EN 0x02 79 | #define SDHCI_TRNS_AUTO_CMD12 0x04 80 | +#define SDHCI_TRNS_AUTO_CMD23 0x08 81 | #define SDHCI_TRNS_READ 0x10 82 | #define SDHCI_TRNS_MULTI 0x20 83 | 84 | diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h 85 | index 73e27ba..6a68c4e 100644 86 | --- a/include/linux/mmc/sdhci.h 87 | +++ b/include/linux/mmc/sdhci.h 88 | @@ -114,6 +114,7 @@ struct sdhci_host { 89 | #define SDHCI_SDR50_NEEDS_TUNING (1<<4) /* SDR50 needs tuning */ 90 | #define SDHCI_NEEDS_RETUNING (1<<5) /* Host needs retuning */ 91 | #define SDHCI_AUTO_CMD12 (1<<6) /* Auto CMD12 support */ 92 | +#define SDHCI_AUTO_CMD23 (1<<7) /* Auto CMD23 support */ 93 | 94 | unsigned int version; /* SDHCI spec. version */ 95 | 96 | -- 97 | 1.7.0.4 98 | 99 | -------------------------------------------------------------------------------- /aos/arch/arm/div64.S: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/arm/div64.S 3 | * 4 | * Optimized computation of 64-bit dividend / 32-bit divisor 5 | * 6 | * Author: Nicolas Pitre 7 | * Created: Oct 5, 2003 8 | * Copyright: Monta Vista Software, Inc. 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 as 12 | * published by the Free Software Foundation. 13 | */ 14 | 15 | #include 16 | 17 | /* 18 | * __do_div64: perform a division with 64-bit dividend and 32-bit divisor. 19 | * 20 | * Note: Calling convention is totally non standard for optimal code. 21 | * This is meant to be used by do_div() from include/asm/div64.h only. 22 | * 23 | * Input parameters: 24 | * r1-r0 = dividend (clobbered) 25 | * r4 = divisor (preserved) 26 | * 27 | * Output values: 28 | * r3-r2 = result 29 | * r1 = remainder 30 | * 31 | * Clobbered regs: r0, ip 32 | */ 33 | 34 | ENTRY(__do_div64) 35 | 36 | @ Test for easy paths first. 37 | subs ip, r4, #1 38 | bls 9f @ divisor is 0 or 1 39 | tst ip, r4 40 | beq 8f @ divisor is power of 2 41 | 42 | @ See if we need to handle upper 32-bit result. 43 | cmp r1, r4 44 | mov r3, #0 45 | blo 3f 46 | 47 | @ Align divisor with upper part of dividend. 48 | @ The aligned divisor is stored in r2 preserving the original. 49 | @ The bit position is stored in ip. 50 | 51 | clz r2, r4 52 | clz ip, r1 53 | sub r2, r2, ip 54 | mov ip, #1 55 | mov ip, ip, lsl r2 56 | mov r2, r4, lsl r2 57 | 58 | @ The division loop for needed upper bit positions. 59 | @ Break out early if dividend reaches 0. 60 | 2: cmp r1, r2 61 | orrcs r3, r3, ip 62 | subcss r1, r1, r2 63 | movnes ip, ip, lsr #1 64 | mov r2, r2, lsr #1 65 | bne 2b 66 | 67 | @ See if we need to handle lower 32-bit result. 68 | 3: cmp r1, #0 69 | mov r2, #0 70 | cmpeq r0, r4 71 | movlo r1, r0 72 | movlo pc, lr 73 | 74 | @ The division loop for lower bit positions. 75 | @ Here we shift remainer bits leftwards rather than moving the 76 | @ divisor for comparisons, considering the carry-out bit as well. 77 | mov ip, #0x80000000 78 | 4: movs r0, r0, lsl #1 79 | adcs r1, r1, r1 80 | beq 6f 81 | cmpcc r1, r4 82 | 5: orrcs r2, r2, ip 83 | subcs r1, r1, r4 84 | movs ip, ip, lsr #1 85 | bne 4b 86 | mov pc, lr 87 | 88 | @ The top part of remainder became zero. If carry is set 89 | @ (the 33th bit) this is a false positive so resume the loop. 90 | @ Otherwise, if lower part is also null then we are done. 91 | 6: bcs 5b 92 | cmp r0, #0 93 | moveq pc, lr 94 | 95 | @ We still have remainer bits in the low part. Bring them up. 96 | 97 | clz r1, r0 @ we know r1 is zero here so... 98 | add r1, r1, #1 99 | mov r0, r0, lsl r1 100 | mov ip, ip, lsr r1 101 | 102 | @ Current remainder is now 1. It is worthless to compare with 103 | @ divisor at this point since divisor can not be smaller than 3 here. 104 | @ If possible, branch for another shift in the division loop. 105 | @ If no bit position left then we are done. 106 | movs ip, ip, lsr #1 107 | mov r1, #1 108 | bne 4b 109 | mov pc, lr 110 | 111 | 8: @ Division by a power of 2: determine what that divisor order is 112 | @ then simply shift values around 113 | 114 | clz ip, r4 115 | rsb ip, ip, #31 116 | 117 | mov r3, r1, lsr ip 118 | mov r2, r0, lsr ip 119 | rsb ip, ip, #32 120 | orr r2, r2, r1, lsl ip 121 | mov r1, r0, lsl ip 122 | mov r1, r1, lsr ip 123 | mov pc, lr 124 | 125 | @ eq -> division by 1: obvious enough... 126 | 9: moveq r2, r0 127 | moveq r3, r1 128 | moveq r1, #0 129 | moveq pc, lr 130 | 131 | @ Division by 0: 132 | str lr, [sp, #-8]! 133 | bl __div0 134 | 135 | @ as wrong as it could be... 136 | mov r2, #0 137 | mov r3, #0 138 | mov r1, #0 139 | ldr pc, [sp], #8 140 | 141 | ENDPROC(__do_div64) 142 | -------------------------------------------------------------------------------- /uefi/0001-ArmPkg-DebugPeCoffExtraActionLib.patch: -------------------------------------------------------------------------------- 1 | From e4dc7a7977921ce9912c69e1177fc63cd926e529 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 11 May 2011 23:04:42 -0500 4 | Subject: [PATCH] ArmPkg: DebugPeCoffExtraActionLib 5 | 6 | Don't crash if PdbPointer is NULL, hence no debugging data. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | .../DebugPeCoffExtraActionLib.c | 27 +++++++++++--------- 11 | 1 files changed, 15 insertions(+), 12 deletions(-) 12 | 13 | diff --git a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 14 | index 5bd1a9d..8af7d9b 100755 15 | --- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 16 | +++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c 17 | @@ -79,15 +79,17 @@ PeCoffLoaderRelocateImageExtraAction ( 18 | { 19 | CHAR8 Temp[512]; 20 | 21 | + if (ImageContext->PdbPointer) { 22 | #ifdef __CC_ARM 23 | - // Print out the command for the RVD debugger to load symbols for this image 24 | - DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); 25 | + // Print out the command for the RVD debugger to load symbols for this image 26 | + DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); 27 | #elif __GNUC__ 28 | - // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required 29 | - DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); 30 | + // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required 31 | + DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); 32 | #else 33 | - DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint))); 34 | + DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint))); 35 | #endif 36 | + } 37 | } 38 | 39 | 40 | @@ -109,16 +111,17 @@ PeCoffLoaderUnloadImageExtraAction ( 41 | ) 42 | { 43 | CHAR8 Temp[512]; 44 | - 45 | + 46 | + if (ImageContext->PdbPointer) { 47 | #ifdef __CC_ARM 48 | - { 49 | - // Print out the command for the RVD debugger to load symbols for this image 50 | + 51 | + // Print out the command for the RVD debugger to load symbols for this image 52 | DEBUG ((EFI_D_ERROR, "unload symbols_only %a", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)))); 53 | - } 54 | #elif __GNUC__ 55 | - // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required 56 | - DEBUG ((EFI_D_ERROR, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); 57 | + // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required 58 | + DEBUG ((EFI_D_ERROR, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer, Temp, sizeof (Temp)), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders))); 59 | #else 60 | - DEBUG ((EFI_D_ERROR, "Unloading %a", ImageContext->PdbPointer)); 61 | + DEBUG ((EFI_D_ERROR, "Unloading %a", ImageContext->PdbPointer)); 62 | #endif 63 | + } 64 | } 65 | -- 66 | 1.7.0.4 67 | 68 | -------------------------------------------------------------------------------- /linux/3.2/olpc/fiq/0005-Kernel-Rename-kdb_syslog_data-and-separate-from-KDB-.patch: -------------------------------------------------------------------------------- 1 | From aa44f64e0fb74c915a3a152025cdbf343e87c71c Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Tue, 27 Sep 2011 03:02:51 -0400 4 | Subject: [PATCH 5/7] Kernel: Rename kdb_syslog_data and separate from KDB 5 | config. 6 | 7 | The routine is useful for other debuggers as well that need kmesg 8 | output. 9 | 10 | Signed-off-by: Andrei Warkentin 11 | --- 12 | include/linux/printk.h | 1 + 13 | kernel/debug/kdb/kdb_main.c | 2 +- 14 | kernel/debug/kdb/kdb_private.h | 1 - 15 | kernel/printk.c | 6 +++--- 16 | lib/Kconfig.debug | 6 ++++++ 17 | lib/Kconfig.kgdb | 1 + 18 | 6 files changed, 12 insertions(+), 5 deletions(-) 19 | 20 | diff --git a/include/linux/printk.h b/include/linux/printk.h 21 | index 0101d55..7c1ad84 100644 22 | --- a/include/linux/printk.h 23 | +++ b/include/linux/printk.h 24 | @@ -306,4 +306,5 @@ static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type, 25 | 26 | #endif 27 | 28 | +void dbg_syslog_data(char *syslog_data[]); 29 | #endif 30 | diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c 31 | index be14779..8904eb1 100644 32 | --- a/kernel/debug/kdb/kdb_main.c 33 | +++ b/kernel/debug/kdb/kdb_main.c 34 | @@ -2063,7 +2063,7 @@ static int kdb_dmesg(int argc, const char **argv) 35 | 36 | /* syslog_data[0,1] physical start, end+1. syslog_data[2,3] 37 | * logical start, end+1. */ 38 | - kdb_syslog_data(syslog_data); 39 | + dbg_syslog_data(syslog_data); 40 | if (syslog_data[2] == syslog_data[3]) 41 | return 0; 42 | logsize = syslog_data[1] - syslog_data[0]; 43 | diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h 44 | index 35d69ed..08e1c5d 100644 45 | --- a/kernel/debug/kdb/kdb_private.h 46 | +++ b/kernel/debug/kdb/kdb_private.h 47 | @@ -207,7 +207,6 @@ extern char kdb_grep_string[]; 48 | extern int kdb_grep_leading; 49 | extern int kdb_grep_trailing; 50 | extern char *kdb_cmds[]; 51 | -extern void kdb_syslog_data(char *syslog_data[]); 52 | extern unsigned long kdb_task_state_string(const char *); 53 | extern char kdb_task_state_char (const struct task_struct *); 54 | extern unsigned long kdb_task_state(const struct task_struct *p, 55 | diff --git a/kernel/printk.c b/kernel/printk.c 56 | index 3518539..5aa12bd 100644 57 | --- a/kernel/printk.c 58 | +++ b/kernel/printk.c 59 | @@ -486,13 +486,13 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len) 60 | return do_syslog(type, buf, len, SYSLOG_FROM_CALL); 61 | } 62 | 63 | -#ifdef CONFIG_KGDB_KDB 64 | +#ifdef CONFIG_DBG_SYSLOG_DATA 65 | /* kdb dmesg command needs access to the syslog buffer. do_syslog() 66 | * uses locks so it cannot be used during debugging. Just tell kdb 67 | * where the start and end of the physical and logical logs are. This 68 | * is equivalent to do_syslog(3). 69 | */ 70 | -void kdb_syslog_data(char *syslog_data[4]) 71 | +void dbg_syslog_data(char *syslog_data[4]) 72 | { 73 | syslog_data[0] = log_buf; 74 | syslog_data[1] = log_buf + log_buf_len; 75 | @@ -500,7 +500,7 @@ void kdb_syslog_data(char *syslog_data[4]) 76 | (logged_chars < log_buf_len ? logged_chars : log_buf_len); 77 | syslog_data[3] = log_buf + log_end; 78 | } 79 | -#endif /* CONFIG_KGDB_KDB */ 80 | +#endif /* CONFIG_DGB_SYSLOG_DATA */ 81 | 82 | /* 83 | * Call the console drivers on a range of log_buf 84 | diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug 85 | index dd373c8..d13a9b8 100644 86 | --- a/lib/Kconfig.debug 87 | +++ b/lib/Kconfig.debug 88 | @@ -1261,3 +1261,9 @@ source "lib/Kconfig.kmemcheck" 89 | 90 | config TEST_KSTRTOX 91 | tristate "Test kstrto*() family of functions at runtime" 92 | + 93 | +config DBG_SYSLOG_DATA 94 | + bool "DBG_SYSLOG_DATA: Debug access to kmesg" 95 | + default n 96 | + help 97 | + This is used by various debuggers to get access to kmesg log. 98 | diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb 99 | index 43cb93f..8826f5a 100644 100 | --- a/lib/Kconfig.kgdb 101 | +++ b/lib/Kconfig.kgdb 102 | @@ -69,6 +69,7 @@ config KGDB_LOW_LEVEL_TRAP 103 | config KGDB_KDB 104 | bool "KGDB_KDB: include kdb frontend for kgdb" 105 | default n 106 | + select DBG_SYSLOG_DATA 107 | help 108 | KDB frontend for kernel 109 | 110 | -- 111 | 1.7.6.1 112 | 113 | -------------------------------------------------------------------------------- /linux/3.2/kgdb/0001-KDB-Make-LINES-an-internal-variable.patch: -------------------------------------------------------------------------------- 1 | From c57d37ae9d019ec92daa15a21270f5a4c82a3977 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Fri, 17 Feb 2012 19:51:07 -0500 4 | Subject: [PATCH 1/7] KDB: Make LINES an internal variable. 5 | 6 | 1) If you run 'dumpall', LINES will remain set to 7 | 10000, and you might wonder why dmesg now doesn't 8 | page. 9 | 2) If you run any command that sets LINES, you will 10 | eventually exhaust the heap. 11 | 12 | To address (1), you can save and restore across 13 | calls to "defcmd" commands, which might contain 14 | "set LINES". This becomes awkward with keeping 15 | LINES in env, but there is no real reason why 16 | LINES cannot be treated as an internal variable. 17 | Additionally, you get rid of the (small) kdb heap 18 | usage for LINES. 19 | 20 | Signed-off-by: Andrei Warkentin 21 | --- 22 | kernel/debug/kdb/kdb_io.c | 4 ++-- 23 | kernel/debug/kdb/kdb_main.c | 29 ++++++++++++++++++++++++++--- 24 | kernel/debug/kdb/kdb_private.h | 1 + 25 | 3 files changed, 29 insertions(+), 5 deletions(-) 26 | 27 | diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c 28 | index 4802eb5..5eb7e23 100644 29 | --- a/kernel/debug/kdb/kdb_io.c 30 | +++ b/kernel/debug/kdb/kdb_io.c 31 | @@ -580,8 +580,8 @@ int vkdb_printf(const char *fmt, va_list ap) 32 | __acquire(kdb_printf_lock); 33 | } 34 | 35 | - diag = kdbgetintenv("LINES", &linecount); 36 | - if (diag || linecount <= 1) 37 | + linecount = kdb_lines; 38 | + if (linecount <= 1) 39 | linecount = 24; 40 | 41 | diag = kdbgetintenv("LOGGING", &logging); 42 | diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c 43 | index e2ae734..ea143ce 100644 44 | --- a/kernel/debug/kdb/kdb_main.c 45 | +++ b/kernel/debug/kdb/kdb_main.c 46 | @@ -60,6 +60,7 @@ atomic_t kdb_event; 47 | int kdb_initial_cpu = -1; /* cpu number that owns kdb */ 48 | int kdb_nextline = 1; 49 | int kdb_state; /* General KDB state */ 50 | +int kdb_lines = 0; /* Lines displayed at once */ 51 | 52 | struct task_struct *kdb_current_task; 53 | EXPORT_SYMBOL(kdb_current_task); 54 | @@ -386,6 +387,18 @@ int kdb_set(int argc, const char **argv) 55 | | (debugflags << KDB_DEBUG_FLAG_SHIFT); 56 | 57 | return 0; 58 | + } else if (strcmp(argv[1], "LINES") == 0) { 59 | + int lines; 60 | + char *cp; 61 | + 62 | + lines = simple_strtol(argv[2], &cp, 0); 63 | + if (cp == argv[2]) { 64 | + kdb_printf("kdb: illegal LINES value '%s'\n", 65 | + argv[2]); 66 | + return 0; 67 | + } 68 | + kdb_lines = lines; 69 | + return 0; 70 | } 71 | 72 | /* 73 | @@ -721,8 +734,11 @@ static int kdb_defcmd(int argc, const char **argv) 74 | */ 75 | static int kdb_exec_defcmd(int argc, const char **argv) 76 | { 77 | - int i, ret; 78 | + int i; 79 | + int oldlines; 80 | struct defcmd_set *s; 81 | + int ret = 0; 82 | + 83 | if (argc != 0) 84 | return KDB_ARGCOUNT; 85 | for (s = defcmd_set, i = 0; i < defcmd_set_count; ++i, ++s) { 86 | @@ -734,6 +750,9 @@ static int kdb_exec_defcmd(int argc, const char **argv) 87 | argv[0]); 88 | return KDB_NOTIMP; 89 | } 90 | + 91 | + /* command might have overridden LINES */ 92 | + oldlines = kdb_lines; 93 | for (i = 0; i < s->count; ++i) { 94 | /* Recursive use of kdb_parse, do not use argv after 95 | * this point */ 96 | @@ -741,9 +760,10 @@ static int kdb_exec_defcmd(int argc, const char **argv) 97 | kdb_printf("[%s]kdb> %s\n", s->name, s->command[i]); 98 | ret = kdb_parse(s->command[i]); 99 | if (ret) 100 | - return ret; 101 | + break; 102 | } 103 | - return 0; 104 | + kdb_lines = oldlines; 105 | + return ret; 106 | } 107 | 108 | /* Command history */ 109 | @@ -2026,6 +2046,9 @@ static int kdb_env(int argc, const char **argv) 110 | if (KDB_DEBUG(MASK)) 111 | kdb_printf("KDBFLAGS=0x%x\n", kdb_flags); 112 | 113 | + if (kdb_lines) 114 | + kdb_printf("LINES=%d\n", kdb_lines); 115 | + 116 | return 0; 117 | } 118 | 119 | diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h 120 | index e381d10..41a221f 100644 121 | --- a/kernel/debug/kdb/kdb_private.h 122 | +++ b/kernel/debug/kdb/kdb_private.h 123 | @@ -154,6 +154,7 @@ extern int kdb_state; 124 | #define KDB_STATE_CLEAR(flag) ((void)(kdb_state &= ~KDB_STATE_##flag)) 125 | 126 | extern int kdb_nextline; /* Current number of lines displayed */ 127 | +extern int kdb_lines; /* Limit on number of lines displayed at once. */ 128 | 129 | typedef struct _kdb_bp { 130 | unsigned long bp_addr; /* Address breakpoint is present at */ 131 | -- 132 | 1.7.9.2 133 | 134 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/README: -------------------------------------------------------------------------------- 1 | Loop device parser support. 2 | =========================== 3 | 4 | These are my work-in-progress patches for developing 5 | VHD/VMDK/qcow and other-virtual-disk support in loop device via 6 | the addition of loop parser support and parser implementations. 7 | 8 | Patches are now rebased to linux-next (as of 9/26/2011). 9 | 10 | Performance is tested using superalign (https://github.com/andreiw/superalign) 11 | 12 | I think a hallmark of good design isn't just time and space considerations, but 13 | also ease of implementation. It's roughly 3 hours to implement the QCOW (v1) logic 14 | and test. It's been about 8 to implement and test dynamic VHD - and you get better 15 | use of unallocated space for QCOW. 16 | 17 | Ex: for 100m qcow and VHD at default settings, empty disks take up 448 and 2.5k 18 | respectively. Formatted with mkfs.ext2, they take up 3.3m and 24.3m respectively. 19 | Astounding. 20 | 21 | VHD spec is at: 22 | http://www.microsoft.com/download/en/details.aspx?id=23850 23 | 24 | QCOW spec is at: 25 | http://people.gnome.org/~markmc/qcow-image-format-version-1.html 26 | 27 | VMDK spec is at: 28 | http://www.vmware.com/technical-resources/interfaces/vmdk.html 29 | 30 | Using. 31 | ====== 32 | 33 | Apply patches. Your .config should have something like: 34 | 35 | CONFIG_BLK_DEV_LOOP=y 36 | CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 37 | CONFIG_BLK_DEV_LOOP_UTIL=y 38 | CONFIG_BLK_DEV_VHDLOOP=y 39 | CONFIG_BLK_DEV_QCOWLOOP=y 40 | CONFIG_BLK_DEV_VMDKLOOP=y 41 | 42 | Mounting is easy, since the losetup interface isn't (and won't be) 43 | changing. 44 | 45 | $ losetup /dev/loop0 /path/to/image 46 | 47 | You will see some acknowledging messages from the kernel regarding 48 | image type and loop size. 49 | 50 | Your either want to set loop.max_parts to something non-zero (10 sounds good to me), 51 | or use kpartx to actually see partitions on devices. 52 | 53 | To use COW disk, you need something to generate the already-present 54 | LOOP_CHANGE_FD loop ioctl. The flow here is that you need to 55 | losetup the parent image, then LOOP_CHANGE_FD to the child. 56 | The kernel will do it's best to prevent you from doing somthing dumb, 57 | by verifying the relation. 58 | 59 | The minimal code to do the change operation would be something like: 60 | 61 | int main(int argc, char **argv) 62 | { 63 | return ioctl(open(argv[1], O_RDWR), 64 | LOOP_CHANGE_FD, 65 | open(argv[2], O_RDWR)); 66 | } 67 | 68 | 69 | To generate VHDs you can use my vhdtool (https://github.com/andreiw/vhdtool), which 70 | allows you to fine-tune metadata details for dynamic disks (and unlike qemu-img, doesn't 71 | create b0rked images). 72 | 73 | For other image types `man 1 qemu-img` (obviously requires qemu installed). 74 | 75 | To-do. 76 | ====== 77 | 78 | VHD parser to-do: 79 | 1) Fixed-size VHDs (Done!) 80 | 2) Dynamic VHDs (Done!) 81 | 3) Differencing VHDs (Should be trivial, since it's a special 82 | case of dynamic VHDs) 83 | 4) Benching against exsting nbd/fuse-based solutions. 84 | 6) Optimizations of read/write path. 85 | 8) Parser options and backwards-compat loop_info changes. 86 | 87 | QCOW parser to-do: 88 | 1) Support RW on v1 (done!) 89 | 2) Support v2. 90 | 3) Support COW disks (done!) 91 | 4) Support compressed sectors (requires changes to generic sparse code). 92 | 93 | VMDK parser to do: 94 | 1) Support RO on hosted extents (done!) 95 | 2) Support RW on hosted extents (done!) 96 | 3) Support ESX extents. 97 | 4) Support COW. 98 | 99 | Common: 100 | 1) Think about and split out common functionality: it's 101 | painful how similar both the VHD and QCOW parsers look, 102 | from an internal data structure POV. (done!) 103 | 2) lo_file management in loop.c is crucial for differencing/COW 104 | disk support (done!) 105 | 3) Think about a common interface for dealing with COW/differencing 106 | disks. It looks like change_fd is the right mechanism, just need 107 | to figure out how to prevent silly things from happening (done!) 108 | 4) Comment everything before submitting to LKML for a shoot-down. 109 | 5) Get flamed by LKML ;-). 110 | 111 | Notes: 112 | Previous versions used a complicated scheme to cache metadata, but 113 | tests have pointed out that just reading/writing ended up being just 114 | as good and possibly faster to caching metadata - after all, it's 115 | already getting cached by the page and buffer caches. So the metadata 116 | caching has been removed, at the additional benefit of clearer code 117 | with less memory overhead. 118 | 119 | Contact Info 120 | ============ 121 | 122 | Andrei Warkentin (andrey.warkentin@gmail.com, andreiw@vmware.com, andreiw@msalumni.com) -------------------------------------------------------------------------------- /aos/include/asm-arm/stdarg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1989, 1997, 1998, 1999, 2000, 2009 Free Software Foundation, Inc. 2 | 3 | This file is part of GCC. 4 | 5 | GCC is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 9 | 10 | GCC is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | Under Section 7 of GPL version 3, you are granted additional 16 | permissions described in the GCC Runtime Library Exception, version 17 | 3.1, as published by the Free Software Foundation. 18 | 19 | You should have received a copy of the GNU General Public License and 20 | a copy of the GCC Runtime Library Exception along with this program; 21 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 22 | . */ 23 | 24 | /* 25 | * ISO C Standard: 7.15 Variable arguments 26 | */ 27 | 28 | #ifndef _STDARG_H 29 | #ifndef _ANSI_STDARG_H_ 30 | #ifndef __need___va_list 31 | #define _STDARG_H 32 | #define _ANSI_STDARG_H_ 33 | #endif /* not __need___va_list */ 34 | #undef __need___va_list 35 | 36 | /* Define __gnuc_va_list. */ 37 | 38 | #ifndef __GNUC_VA_LIST 39 | #define __GNUC_VA_LIST 40 | typedef __builtin_va_list __gnuc_va_list; 41 | #endif 42 | 43 | /* Define the standard macros for the user, 44 | if this invocation was from the user program. */ 45 | #ifdef _STDARG_H 46 | 47 | #define va_start(v,l) __builtin_va_start(v,l) 48 | #define va_end(v) __builtin_va_end(v) 49 | #define va_arg(v,l) __builtin_va_arg(v,l) 50 | #if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L || defined(__GXX_EXPERIMENTAL_CXX0X__) 51 | #define va_copy(d,s) __builtin_va_copy(d,s) 52 | #endif 53 | #define __va_copy(d,s) __builtin_va_copy(d,s) 54 | 55 | /* Define va_list, if desired, from __gnuc_va_list. */ 56 | /* We deliberately do not define va_list when called from 57 | stdio.h, because ANSI C says that stdio.h is not supposed to define 58 | va_list. stdio.h needs to have access to that data type, 59 | but must not use that name. It should use the name __gnuc_va_list, 60 | which is safe because it is reserved for the implementation. */ 61 | 62 | #ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */ 63 | #undef _VA_LIST 64 | #endif 65 | 66 | #ifdef _BSD_VA_LIST 67 | #undef _BSD_VA_LIST 68 | #endif 69 | 70 | #if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST)) 71 | /* SVR4.2 uses _VA_LIST for an internal alias for va_list, 72 | so we must avoid testing it and setting it here. 73 | SVR4 uses _VA_LIST as a flag in stdarg.h, but we should 74 | have no conflict with that. */ 75 | #ifndef _VA_LIST_ 76 | #define _VA_LIST_ 77 | #ifdef __i860__ 78 | #ifndef _VA_LIST 79 | #define _VA_LIST va_list 80 | #endif 81 | #endif /* __i860__ */ 82 | typedef __gnuc_va_list va_list; 83 | #ifdef _SCO_DS 84 | #define __VA_LIST 85 | #endif 86 | #endif /* _VA_LIST_ */ 87 | #else /* not __svr4__ || _SCO_DS */ 88 | 89 | /* The macro _VA_LIST_ is the same thing used by this file in Ultrix. 90 | But on BSD NET2 we must not test or define or undef it. 91 | (Note that the comments in NET 2's ansi.h 92 | are incorrect for _VA_LIST_--see stdio.h!) */ 93 | #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT) 94 | /* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */ 95 | #ifndef _VA_LIST_DEFINED 96 | /* The macro _VA_LIST is used in SCO Unix 3.2. */ 97 | #ifndef _VA_LIST 98 | /* The macro _VA_LIST_T_H is used in the Bull dpx2 */ 99 | #ifndef _VA_LIST_T_H 100 | /* The macro __va_list__ is used by BeOS. */ 101 | #ifndef __va_list__ 102 | typedef __gnuc_va_list va_list; 103 | #endif /* not __va_list__ */ 104 | #endif /* not _VA_LIST_T_H */ 105 | #endif /* not _VA_LIST */ 106 | #endif /* not _VA_LIST_DEFINED */ 107 | #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__)) 108 | #define _VA_LIST_ 109 | #endif 110 | #ifndef _VA_LIST 111 | #define _VA_LIST 112 | #endif 113 | #ifndef _VA_LIST_DEFINED 114 | #define _VA_LIST_DEFINED 115 | #endif 116 | #ifndef _VA_LIST_T_H 117 | #define _VA_LIST_T_H 118 | #endif 119 | #ifndef __va_list__ 120 | #define __va_list__ 121 | #endif 122 | 123 | #endif /* not _VA_LIST_, except on certain systems */ 124 | 125 | #endif /* not __svr4__ */ 126 | 127 | #endif /* _STDARG_H */ 128 | 129 | #endif /* not _ANSI_STDARG_H_ */ 130 | #endif /* not _STDARG_H */ 131 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0001-Loop-Allow-non-linear-mapping-between-loop-and-backi.patch: -------------------------------------------------------------------------------- 1 | From 4d8877304d381658722152d9ee7ba4693849e855 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Mon, 1 Aug 2011 20:09:58 -0500 4 | Subject: [PATCH 01/18] Loop: Allow non-linear mapping between loop and backing file. 5 | 6 | This enables development of parsers for various disk-file 7 | formats, such as dynamic VHD, where 512K-2MB chunks can 8 | be located non-sequentially and are looked up through 9 | an indirection table. 10 | 11 | Change-Id: I2c70f1d11ee126a305d7beb48ea8df0345db6405 12 | Signed-off-by: Andrei Warkentin 13 | --- 14 | drivers/block/loop.c | 71 ++++++++++++++++++++++++++++++++++++++++++++----- 15 | include/linux/loop.h | 6 ++++ 16 | 2 files changed, 69 insertions(+), 8 deletions(-) 17 | 18 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 19 | index 91797bb..6167026 100644 20 | --- a/drivers/block/loop.c 21 | +++ b/drivers/block/loop.c 22 | @@ -84,6 +84,27 @@ static int max_part; 23 | static int part_shift; 24 | 25 | /* 26 | + * This is the almost do-nothing transform for regular loopback 27 | + * images. The backing file store linearly maps block to file 28 | + * position, with an offset supported. 29 | + */ 30 | +struct bio_vec *raw_transform(struct loop_device *lo, 31 | + loff_t pos, loff_t *fpos, 32 | + struct bio_vec *in, 33 | + struct bio_vec *out, 34 | + struct bio_vec *rem) 35 | +{ 36 | + *fpos = pos + lo->lo_offset; 37 | + 38 | + /* Ensures "remainder" bvec is never examined in 39 | + lo_send and lo_receive. */ 40 | + rem->bv_len = 0; 41 | + 42 | + /* No need to split bvec as data is always contiguous. */ 43 | + return in; 44 | +} 45 | + 46 | +/* 47 | * Transfer functions 48 | */ 49 | static int transfer_none(struct loop_device *lo, int cmd, 50 | @@ -345,7 +366,8 @@ static int lo_send(struct loop_device *lo, struct bio *bio, loff_t pos) 51 | { 52 | int (*do_lo_send)(struct loop_device *, struct bio_vec *, loff_t, 53 | struct page *page); 54 | - struct bio_vec *bvec; 55 | + loff_t fpos; 56 | + struct bio_vec *bvec, *vec, ovec, rvec; 57 | struct page *page = NULL; 58 | int i, ret = 0; 59 | 60 | @@ -361,10 +383,26 @@ static int lo_send(struct loop_device *lo, struct bio *bio, loff_t pos) 61 | } 62 | } 63 | bio_for_each_segment(bvec, bio, i) { 64 | - ret = do_lo_send(lo, bvec, pos, page); 65 | + vec = bvec; 66 | + 67 | + do { 68 | + vec = lo->transform(lo, pos, &fpos, 69 | + vec, &ovec, &rvec); 70 | + if (IS_ERR(vec)) { 71 | + ret = PTR_ERR(vec); 72 | + break; 73 | + } 74 | + 75 | + ret = do_lo_send(lo, vec, fpos, page); 76 | + if (ret < 0) 77 | + break; 78 | + 79 | + pos += vec->bv_len; 80 | + vec = &rvec; 81 | + } while (vec->bv_len != 0); 82 | + 83 | if (ret < 0) 84 | break; 85 | - pos += bvec->bv_len; 86 | } 87 | if (page) { 88 | kunmap(page); 89 | @@ -457,24 +495,40 @@ do_lo_receive(struct loop_device *lo, 90 | static int 91 | lo_receive(struct loop_device *lo, struct bio *bio, int bsize, loff_t pos) 92 | { 93 | - struct bio_vec *bvec; 94 | + loff_t fpos; 95 | + struct bio_vec *bvec, *vec, ovec, rvec; 96 | int i, ret = 0; 97 | 98 | bio_for_each_segment(bvec, bio, i) { 99 | - ret = do_lo_receive(lo, bvec, bsize, pos); 100 | + vec = bvec; 101 | + do { 102 | + vec = lo->transform(lo, pos, &fpos, 103 | + vec, &ovec, &rvec); 104 | + if (IS_ERR(vec)) { 105 | + ret = PTR_ERR(vec); 106 | + break; 107 | + } 108 | + 109 | + ret = do_lo_receive(lo, vec, bsize, fpos); 110 | + if (ret < 0) 111 | + break; 112 | + 113 | + pos += vec->bv_len; 114 | + vec = &rvec; 115 | + } while (vec->bv_len != 0); 116 | + 117 | if (ret < 0) 118 | break; 119 | - pos += bvec->bv_len; 120 | } 121 | return ret; 122 | } 123 | 124 | static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) 125 | { 126 | - loff_t pos; 127 | int ret; 128 | + loff_t pos; 129 | 130 | - pos = ((loff_t) bio->bi_sector << 9) + lo->lo_offset; 131 | + pos = ((loff_t) bio->bi_sector << 9); 132 | 133 | if (bio_rw(bio) == WRITE) { 134 | bool barrier = !!(bio->bi_rw & REQ_HARDBARRIER); 135 | @@ -819,6 +873,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode, 136 | lo->ioctl = NULL; 137 | lo->lo_sizelimit = 0; 138 | lo->old_gfp_mask = mapping_gfp_mask(mapping); 139 | + lo->transform = raw_transform; 140 | mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS)); 141 | 142 | bio_list_init(&lo->lo_bio_list); 143 | diff --git a/include/linux/loop.h b/include/linux/loop.h 144 | index 66c194e..fa13570 100644 145 | --- a/include/linux/loop.h 146 | +++ b/include/linux/loop.h 147 | @@ -65,6 +65,12 @@ struct loop_device { 148 | struct request_queue *lo_queue; 149 | struct gendisk *lo_disk; 150 | struct list_head lo_list; 151 | + 152 | + struct bio_vec *(*transform)(struct loop_device *lo, 153 | + loff_t pos, loff_t *fpos, 154 | + struct bio_vec *in, 155 | + struct bio_vec *out, 156 | + struct bio_vec *rem); 157 | }; 158 | 159 | #endif /* __KERNEL__ */ 160 | -- 161 | 1.7.0.4 162 | 163 | -------------------------------------------------------------------------------- /uefi/GSoC2012/0001-MPS-Test-program-for-the-protocol-implementation.patch: -------------------------------------------------------------------------------- 1 | From c6bff0a4535689c1c08b9588443420cc5c8f3315 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Fri, 20 Apr 2012 22:43:19 -0400 4 | Subject: [PATCH 1/5] MPS: Test program for the protocol implementation. 5 | 6 | This will test the MPS protocol. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | OvmfPkg/Application/MPTest/MPTest.c | 64 +++++++++++++++++++++++++++++++++++ 11 | OvmfPkg/Application/MPTest/MPTest.inf | 49 +++++++++++++++++++++++++++ 12 | 2 files changed, 113 insertions(+) 13 | create mode 100644 OvmfPkg/Application/MPTest/MPTest.c 14 | create mode 100644 OvmfPkg/Application/MPTest/MPTest.inf 15 | 16 | diff --git a/OvmfPkg/Application/MPTest/MPTest.c b/OvmfPkg/Application/MPTest/MPTest.c 17 | new file mode 100644 18 | index 0000000..eba199b 19 | --- /dev/null 20 | +++ b/OvmfPkg/Application/MPTest/MPTest.c 21 | @@ -0,0 +1,64 @@ 22 | +/** @file 23 | + MP support testing. 24 | + 25 | + Copyright (c) 2012 Andrei Warkentin 26 | + 27 | + This program and the accompanying materials 28 | + are licensed and made available under the terms and conditions of the BSD License 29 | + which accompanies this distribution. The full text of the license may be found at 30 | + http://opensource.org/licenses/bsd-license.php 31 | + 32 | + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 33 | + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 34 | + 35 | +**/ 36 | + 37 | +#include 38 | +#include 39 | +#include 40 | +#include 41 | +#include 42 | +#include 43 | + 44 | +/** 45 | + The user Entry Point for Application. The user code starts with this function 46 | + as the real entry point for the application. 47 | + 48 | + @param[in] ImageHandle The firmware allocated handle for the EFI image. 49 | + @param[in] SystemTable A pointer to the EFI System Table. 50 | + 51 | + @retval EFI_SUCCESS The entry point is executed successfully. 52 | + @retval other Some error occurs when executing this entry point. 53 | + 54 | +**/ 55 | +EFI_STATUS 56 | +EFIAPI 57 | +UefiMain ( 58 | + IN EFI_HANDLE ImageHandle, 59 | + IN EFI_SYSTEM_TABLE *SystemTable 60 | + ) 61 | +{ 62 | + UINTN Total; 63 | + UINTN Enabled; 64 | + EFI_STATUS Status; 65 | + EFI_MP_SERVICES_PROTOCOL *MPS; 66 | + 67 | + // 68 | + // Use UefiLib Print API to print string to UEFI console 69 | + // 70 | + 71 | + Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **) &MPS); 72 | + if (EFI_ERROR (Status)) { 73 | + Print ((CHAR16*) L"No MP support protocol :-(.\n"); 74 | + return Status; 75 | + } 76 | + 77 | + Print ((CHAR16*) L"MP support present.\n"); 78 | + Status = MPS->GetNumberOfProcessors(MPS, &Total, &Enabled); 79 | + if (!EFI_ERROR (Status)) { 80 | + Print ((CHAR16*) L"Total CPUs: %d\n", Total); 81 | + Print ((CHAR16*) L"Enabled CPUs: %d\n", Enabled); 82 | + } 83 | + 84 | + return Status; 85 | +} 86 | diff --git a/OvmfPkg/Application/MPTest/MPTest.inf b/OvmfPkg/Application/MPTest/MPTest.inf 87 | new file mode 100644 88 | index 0000000..ffb8662 89 | --- /dev/null 90 | +++ b/OvmfPkg/Application/MPTest/MPTest.inf 91 | @@ -0,0 +1,49 @@ 92 | +## @file 93 | +# MP support testing. 94 | +# 95 | +# Exercises the MP support protocol. 96 | +# 97 | +# Copyright (c) 2012 Andrei Warkentin 98 | +# 99 | +# This program and the accompanying materials 100 | +# are licensed and made available under the terms and conditions of the BSD License 101 | +# which accompanies this distribution. The full text of the license may be found at 102 | +# http://opensource.org/licenses/bsd-license.php 103 | +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 104 | +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 105 | +# 106 | +# 107 | +## 108 | + 109 | +[Defines] 110 | + INF_VERSION = 0x00010005 111 | + BASE_NAME = MPTest 112 | + FILE_GUID = 6987936E-ED34-44db-AE97-1FA5E4ED2116 113 | + MODULE_TYPE = UEFI_APPLICATION 114 | + VERSION_STRING = 1.0 115 | + ENTRY_POINT = UefiMain 116 | + 117 | +# 118 | +# The following information is for reference only and not required by the build tools. 119 | +# 120 | +# VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM 121 | +# 122 | + 123 | +[Sources] 124 | + MPTest.c 125 | + 126 | +[Packages] 127 | + MdePkg/MdePkg.dec 128 | + MdeModulePkg/MdeModulePkg.dec 129 | + 130 | +[LibraryClasses] 131 | + UefiApplicationEntryPoint 132 | + UefiBootServicesTableLib 133 | + UefiLib 134 | + 135 | +[FeaturePcd] 136 | + 137 | +[Pcd] 138 | + 139 | +[Protocols] 140 | + gEfiMpServiceProtocolGuid 141 | \ No newline at end of file 142 | -- 143 | 2.5.3 144 | 145 | -------------------------------------------------------------------------------- /linux/3.0/mmc/cmd23/0003-MMC-Implement-MMC_CAP_CMD23-for-SDHCI.patch: -------------------------------------------------------------------------------- 1 | From 9dcb71a1e745786aaf8a331af574392cf6ca2fa4 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 13 Apr 2011 18:01:19 -0500 4 | Subject: [PATCH 3/5] MMC: Implement MMC_CAP_CMD23 for SDHCI. 5 | 6 | Implements support for multiblock transfers bounded 7 | by SET_BLOCK_COUNT (CMD23). 8 | 9 | Cc: arindam.nath@amd.com 10 | Cc: cjb@laptop.org 11 | Cc: arnd@arndb.de 12 | Cc: malchev@google.com 13 | Signed-off-by: Andrei Warkentin 14 | --- 15 | drivers/mmc/host/sdhci.c | 66 ++++++++++++++++++++++++++++++++++----------- 16 | drivers/mmc/host/sdhci.h | 2 +- 17 | include/linux/mmc/sdhci.h | 1 + 18 | 3 files changed, 52 insertions(+), 17 deletions(-) 19 | 20 | diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c 21 | index cc63f5e..3a53512 100644 22 | --- a/drivers/mmc/host/sdhci.c 23 | +++ b/drivers/mmc/host/sdhci.c 24 | @@ -838,9 +838,10 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) 25 | } 26 | 27 | static void sdhci_set_transfer_mode(struct sdhci_host *host, 28 | - struct mmc_data *data) 29 | + struct mmc_command *cmd) 30 | { 31 | u16 mode; 32 | + struct mmc_data *data = cmd->data; 33 | 34 | if (data == NULL) 35 | return; 36 | @@ -848,11 +849,17 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host, 37 | WARN_ON(!host->data); 38 | 39 | mode = SDHCI_TRNS_BLK_CNT_EN; 40 | - if (data->blocks > 1) { 41 | - if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12) 42 | - mode |= SDHCI_TRNS_MULTI | SDHCI_TRNS_ACMD12; 43 | - else 44 | - mode |= SDHCI_TRNS_MULTI; 45 | + if (mmc_op_multi(cmd->opcode) || 46 | + data->blocks > 1) { 47 | + mode |= SDHCI_TRNS_MULTI; 48 | + 49 | + /* 50 | + * If we are sending CMD23, CMD12 never gets sent 51 | + * on successful completion (so no Auto-CMD12). 52 | + */ 53 | + if (!host->mrq->sbc && 54 | + host->flags & SDHCI_AUTO_CMD12) 55 | + mode |= SDHCI_TRNS_AUTO_CMD12; 56 | } 57 | if (data->flags & MMC_DATA_READ) 58 | mode |= SDHCI_TRNS_READ; 59 | @@ -893,7 +900,15 @@ static void sdhci_finish_data(struct sdhci_host *host) 60 | else 61 | data->bytes_xfered = data->blksz * data->blocks; 62 | 63 | - if (data->stop) { 64 | + /* 65 | + * Need to send CMD12 if - 66 | + * a) open-ended multiblock transfer (no CMD23) 67 | + * b) error in multiblock transfer 68 | + */ 69 | + if (data->stop && 70 | + (data->error || 71 | + !host->mrq->sbc)) { 72 | + 73 | /* 74 | * The controller needs a reset of internal state machines 75 | * upon error conditions. 76 | @@ -949,7 +964,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) 77 | 78 | sdhci_writel(host, cmd->arg, SDHCI_ARGUMENT); 79 | 80 | - sdhci_set_transfer_mode(host, cmd->data); 81 | + sdhci_set_transfer_mode(host, cmd); 82 | 83 | if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) { 84 | printk(KERN_ERR "%s: Unsupported response type!\n", 85 | @@ -1004,13 +1019,21 @@ static void sdhci_finish_command(struct sdhci_host *host) 86 | 87 | host->cmd->error = 0; 88 | 89 | - if (host->data && host->data_early) 90 | - sdhci_finish_data(host); 91 | + /* Finished CMD23, now send actual command. */ 92 | + if (host->cmd == host->mrq->sbc) { 93 | + host->cmd = NULL; 94 | + sdhci_send_command(host, host->mrq->cmd); 95 | + } else { 96 | 97 | - if (!host->cmd->data) 98 | - tasklet_schedule(&host->finish_tasklet); 99 | + /* Processed actual command. */ 100 | + if (host->data && host->data_early) 101 | + sdhci_finish_data(host); 102 | 103 | - host->cmd = NULL; 104 | + if (!host->cmd->data) 105 | + tasklet_schedule(&host->finish_tasklet); 106 | + 107 | + host->cmd = NULL; 108 | + } 109 | } 110 | 111 | static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) 112 | @@ -1189,7 +1212,12 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) 113 | #ifndef SDHCI_USE_LEDS_CLASS 114 | sdhci_activate_led(host); 115 | #endif 116 | - if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12) { 117 | + 118 | + /* 119 | + * Ensure we don't send the STOP for non-SET_BLOCK_COUNTED 120 | + * requests if Auto-CMD12 is enabled. 121 | + */ 122 | + if (!mrq->sbc && (host->flags & SDHCI_AUTO_CMD12)) { 123 | if (mrq->stop) { 124 | mrq->data->stop = NULL; 125 | mrq->stop = NULL; 126 | @@ -1227,7 +1255,10 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) 127 | host->mrq = mrq; 128 | } 129 | 130 | - sdhci_send_command(host, mrq->cmd); 131 | + if (mrq->sbc) 132 | + sdhci_send_command(host, mrq->sbc); 133 | + else 134 | + sdhci_send_command(host, mrq->cmd); 135 | } 136 | 137 | mmiowb(); 138 | @@ -2455,7 +2486,10 @@ int sdhci_add_host(struct sdhci_host *host) 139 | } else 140 | mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; 141 | 142 | - mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE; 143 | + mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23; 144 | + 145 | + if (host->quirks & SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12) 146 | + host->flags |= SDHCI_AUTO_CMD12; 147 | 148 | /* 149 | * A controller may support 8-bit width, but the board itself 150 | diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h 151 | index 7e28eec..2c3fbc5 100644 152 | --- a/drivers/mmc/host/sdhci.h 153 | +++ b/drivers/mmc/host/sdhci.h 154 | @@ -36,7 +36,7 @@ 155 | #define SDHCI_TRANSFER_MODE 0x0C 156 | #define SDHCI_TRNS_DMA 0x01 157 | #define SDHCI_TRNS_BLK_CNT_EN 0x02 158 | -#define SDHCI_TRNS_ACMD12 0x04 159 | +#define SDHCI_TRNS_AUTO_CMD12 0x04 160 | #define SDHCI_TRNS_READ 0x10 161 | #define SDHCI_TRNS_MULTI 0x20 162 | 163 | diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h 164 | index e902618..73e27ba 100644 165 | --- a/include/linux/mmc/sdhci.h 166 | +++ b/include/linux/mmc/sdhci.h 167 | @@ -113,6 +113,7 @@ struct sdhci_host { 168 | #define SDHCI_DEVICE_DEAD (1<<3) /* Device unresponsive */ 169 | #define SDHCI_SDR50_NEEDS_TUNING (1<<4) /* SDR50 needs tuning */ 170 | #define SDHCI_NEEDS_RETUNING (1<<5) /* Host needs retuning */ 171 | +#define SDHCI_AUTO_CMD12 (1<<6) /* Auto CMD12 support */ 172 | 173 | unsigned int version; /* SDHCI spec. version */ 174 | 175 | -- 176 | 1.7.0.4 177 | 178 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0007-Loop-Expose-transfer-parameter-into-send-receive-fun.patch: -------------------------------------------------------------------------------- 1 | From 0a2c985673170ecb563dcaa937ee5a80689b8767 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Thu, 11 Aug 2011 14:24:31 -0500 4 | Subject: [PATCH 07/18] Loop: Expose transfer parameter into send/receive funcs. 5 | 6 | Expose the transfer function as a parameter into 7 | do_lo_send/do_lo_receive, so the same code can be 8 | reused for performing direct untransformed file I/O 9 | on behalf of parser code. 10 | 11 | Change-Id: Iaf2b292f5cac7f8f6a06ea7d0ea0caf68b05d35b 12 | Signed-off-by: Andrei Warkentin 13 | --- 14 | drivers/block/loop.c | 35 ++++++++++++++--------------------- 15 | include/linux/loop.h | 10 ++++++---- 16 | 2 files changed, 20 insertions(+), 25 deletions(-) 17 | 18 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 19 | index dcbb205..ecc1fc4 100644 20 | --- a/drivers/block/loop.c 21 | +++ b/drivers/block/loop.c 22 | @@ -192,18 +192,6 @@ figure_loop_size(struct loop_device *lo) 23 | return 0; 24 | } 25 | 26 | -static inline int 27 | -lo_do_transfer(struct loop_device *lo, int cmd, 28 | - struct page *rpage, unsigned roffs, 29 | - struct page *lpage, unsigned loffs, 30 | - int size, sector_t rblock) 31 | -{ 32 | - if (unlikely(!lo->transfer)) 33 | - return 0; 34 | - 35 | - return lo->transfer(lo, cmd, rpage, roffs, lpage, loffs, size, rblock); 36 | -} 37 | - 38 | /** 39 | * do_lo_send_aops - helper for writing data to a loop device 40 | * 41 | @@ -212,6 +200,7 @@ lo_do_transfer(struct loop_device *lo, int cmd, 42 | */ 43 | static int do_lo_send_aops(struct loop_device *lo, 44 | struct lo_file *lo_file, 45 | + loop_xfer transfer, 46 | struct bio_vec *bvec, 47 | loff_t pos, struct page *unused) 48 | { 49 | @@ -245,8 +234,8 @@ static int do_lo_send_aops(struct loop_device *lo, 50 | 51 | file_update_time(file); 52 | 53 | - transfer_result = lo_do_transfer(lo, WRITE, page, offset, 54 | - bvec->bv_page, bv_offs, size, IV); 55 | + transfer_result = transfer(lo, WRITE, page, offset, 56 | + bvec->bv_page, bv_offs, size, IV); 57 | copied = size; 58 | if (unlikely(transfer_result)) 59 | copied = 0; 60 | @@ -308,6 +297,7 @@ static int __do_lo_send_write(struct file *file, 61 | */ 62 | static int do_lo_send_direct_write(struct loop_device *lo, 63 | struct lo_file *lo_file, 64 | + loop_xfer unused, 65 | struct bio_vec *bvec, loff_t pos, 66 | struct page *page) 67 | { 68 | @@ -334,11 +324,12 @@ static int do_lo_send_direct_write(struct loop_device *lo, 69 | */ 70 | static int do_lo_send_write(struct loop_device *lo, 71 | struct lo_file *lo_file, 72 | + loop_xfer transfer, 73 | struct bio_vec *bvec, loff_t pos, 74 | struct page *page) 75 | { 76 | - int ret = lo_do_transfer(lo, WRITE, page, 0, bvec->bv_page, 77 | - bvec->bv_offset, bvec->bv_len, pos >> 9); 78 | + int ret = transfer(lo, WRITE, page, 0, bvec->bv_page, 79 | + bvec->bv_offset, bvec->bv_len, pos >> 9); 80 | if (likely(!ret)) 81 | return __do_lo_send_write(lo_file->file, 82 | page_address(page), bvec->bv_len, 83 | @@ -353,7 +344,7 @@ static int do_lo_send_write(struct loop_device *lo, 84 | static int lo_send(struct loop_device *lo, struct lo_file *lo_file, 85 | struct bio *bio, loff_t pos) 86 | { 87 | - int (*do_lo_send)(struct loop_device *, struct lo_file *, 88 | + int (*do_lo_send)(struct loop_device *, struct lo_file *, loop_xfer, 89 | struct bio_vec *, loff_t, struct page *page); 90 | loff_t fpos; 91 | struct bio_vec *bvec, *vec, ovec, rvec; 92 | @@ -383,7 +374,7 @@ static int lo_send(struct loop_device *lo, struct lo_file *lo_file, 93 | break; 94 | } 95 | 96 | - ret = do_lo_send(lo, lo_file, vec, fpos, page); 97 | + ret = do_lo_send(lo, lo_file, lo->transfer, vec, fpos, page); 98 | if (ret < 0) 99 | break; 100 | 101 | @@ -408,6 +399,7 @@ fail: 102 | 103 | struct lo_read_data { 104 | struct loop_device *lo; 105 | + loop_xfer transfer; 106 | struct page *page; 107 | unsigned offset; 108 | int bsize; 109 | @@ -433,7 +425,7 @@ lo_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf, 110 | if (size > p->bsize) 111 | size = p->bsize; 112 | 113 | - if (lo_do_transfer(lo, READ, page, buf->offset, p->page, p->offset, size, IV)) { 114 | + if (p->transfer(lo, READ, page, buf->offset, p->page, p->offset, size, IV)) { 115 | printk(KERN_ERR "loop: transfer error block %ld\n", 116 | page->index); 117 | size = -EINVAL; 118 | @@ -458,7 +450,7 @@ lo_direct_splice_actor(struct pipe_inode_info *pipe, struct splice_desc *sd) 119 | 120 | static int 121 | do_lo_receive(struct loop_device *lo, struct lo_file *lo_file, 122 | - struct bio_vec *bvec, loff_t pos) 123 | + loop_xfer transfer, struct bio_vec *bvec, loff_t pos) 124 | { 125 | struct lo_read_data cookie; 126 | struct splice_desc sd; 127 | @@ -469,6 +461,7 @@ do_lo_receive(struct loop_device *lo, struct lo_file *lo_file, 128 | cookie.page = bvec->bv_page; 129 | cookie.offset = bvec->bv_offset; 130 | cookie.bsize = lo_file->blocksize; 131 | + cookie.transfer = transfer; 132 | 133 | sd.len = 0; 134 | sd.total_len = bvec->bv_len; 135 | @@ -504,7 +497,7 @@ lo_receive(struct loop_device *lo, struct lo_file *lo_file, 136 | break; 137 | } 138 | 139 | - ret = do_lo_receive(lo, lo_file, vec, fpos); 140 | + ret = do_lo_receive(lo, lo_file, lo->transfer, vec, fpos); 141 | if (ret < 0) 142 | break; 143 | 144 | diff --git a/include/linux/loop.h b/include/linux/loop.h 145 | index 447a427..5ff6d40 100644 146 | --- a/include/linux/loop.h 147 | +++ b/include/linux/loop.h 148 | @@ -145,14 +145,16 @@ struct loop_info64 { 149 | #define LO_CRYPT_CRYPTOAPI 18 150 | #define MAX_LO_CRYPT 20 151 | 152 | +typedef int (*loop_xfer)(struct loop_device *lo, int cmd, 153 | + struct page *raw_page, unsigned raw_off, 154 | + struct page *loop_page, unsigned loop_off, 155 | + int size, sector_t real_block); 156 | + 157 | #ifdef __KERNEL__ 158 | /* Support for loadable transfer modules */ 159 | struct loop_func_table { 160 | int number; /* filter type */ 161 | - int (*transfer)(struct loop_device *lo, int cmd, 162 | - struct page *raw_page, unsigned raw_off, 163 | - struct page *loop_page, unsigned loop_off, 164 | - int size, sector_t real_block); 165 | + loop_xfer transfer; 166 | int (*init)(struct loop_device *, const struct loop_info64 *); 167 | /* release is called from loop_unregister_transfer or clr_fd */ 168 | int (*release)(struct loop_device *); 169 | -- 170 | 1.7.0.4 171 | 172 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0006-Loop-Propagate-lo_file-into-lo_send-lo_receive-path.patch: -------------------------------------------------------------------------------- 1 | From 44af9336a637923afbfa53a4fecb5b44c744a978 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Wed, 10 Aug 2011 17:21:13 -0500 4 | Subject: [PATCH 06/18] Loop: Propagate lo_file into lo_send/lo_receive path. 5 | 6 | This allows lo_send/lo_receive to operate on arbitrary 7 | lo_files. 8 | 9 | Next step is enhancing lo_send/lo_receive to avoid 10 | crypto/parser transformations for internal I/O requests 11 | from the parser. 12 | 13 | Change-Id: Ibc84d02eb5376b8e88b0d84fcc031d9bca0328bb 14 | Signed-off-by: Andrei Warkentin 15 | --- 16 | drivers/block/loop.c | 50 +++++++++++++++++++++++++++++--------------------- 17 | 1 files changed, 29 insertions(+), 21 deletions(-) 18 | 19 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 20 | index c511745..dcbb205 100644 21 | --- a/drivers/block/loop.c 22 | +++ b/drivers/block/loop.c 23 | @@ -210,10 +210,12 @@ lo_do_transfer(struct loop_device *lo, int cmd, 24 | * This is the fast version for backing filesystems which implement the address 25 | * space operations write_begin and write_end. 26 | */ 27 | -static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, 28 | - loff_t pos, struct page *unused) 29 | +static int do_lo_send_aops(struct loop_device *lo, 30 | + struct lo_file *lo_file, 31 | + struct bio_vec *bvec, 32 | + loff_t pos, struct page *unused) 33 | { 34 | - struct file *file = lo->lo_file.file; /* kudos to NFsckingS */ 35 | + struct file *file = lo_file->file; /* kudos to NFsckingS */ 36 | struct address_space *mapping = file->f_mapping; 37 | pgoff_t index; 38 | unsigned offset, bv_offs; 39 | @@ -305,9 +307,11 @@ static int __do_lo_send_write(struct file *file, 40 | * filesystems. 41 | */ 42 | static int do_lo_send_direct_write(struct loop_device *lo, 43 | - struct bio_vec *bvec, loff_t pos, struct page *page) 44 | + struct lo_file *lo_file, 45 | + struct bio_vec *bvec, loff_t pos, 46 | + struct page *page) 47 | { 48 | - ssize_t bw = __do_lo_send_write(lo->lo_file.file, 49 | + ssize_t bw = __do_lo_send_write(lo_file->file, 50 | kmap(bvec->bv_page) + bvec->bv_offset, 51 | bvec->bv_len, pos); 52 | kunmap(bvec->bv_page); 53 | @@ -328,13 +332,15 @@ static int do_lo_send_direct_write(struct loop_device *lo, 54 | * the transformations in place as we do not have direct access to the 55 | * destination pages of the backing file. 56 | */ 57 | -static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec, 58 | - loff_t pos, struct page *page) 59 | +static int do_lo_send_write(struct loop_device *lo, 60 | + struct lo_file *lo_file, 61 | + struct bio_vec *bvec, loff_t pos, 62 | + struct page *page) 63 | { 64 | int ret = lo_do_transfer(lo, WRITE, page, 0, bvec->bv_page, 65 | bvec->bv_offset, bvec->bv_len, pos >> 9); 66 | if (likely(!ret)) 67 | - return __do_lo_send_write(lo->lo_file.file, 68 | + return __do_lo_send_write(lo_file->file, 69 | page_address(page), bvec->bv_len, 70 | pos); 71 | printk(KERN_ERR "loop: Transfer error at byte offset %llu, " 72 | @@ -344,17 +350,18 @@ static int do_lo_send_write(struct loop_device *lo, struct bio_vec *bvec, 73 | return ret; 74 | } 75 | 76 | -static int lo_send(struct loop_device *lo, struct bio *bio, loff_t pos) 77 | +static int lo_send(struct loop_device *lo, struct lo_file *lo_file, 78 | + struct bio *bio, loff_t pos) 79 | { 80 | - int (*do_lo_send)(struct loop_device *, struct bio_vec *, loff_t, 81 | - struct page *page); 82 | + int (*do_lo_send)(struct loop_device *, struct lo_file *, 83 | + struct bio_vec *, loff_t, struct page *page); 84 | loff_t fpos; 85 | struct bio_vec *bvec, *vec, ovec, rvec; 86 | struct page *page = NULL; 87 | int i, ret = 0; 88 | 89 | do_lo_send = do_lo_send_aops; 90 | - if (!(lo->lo_file.flags & LO_FILE_FLAGS_USE_AOPS)) { 91 | + if (!(lo_file->flags & LO_FILE_FLAGS_USE_AOPS)) { 92 | do_lo_send = do_lo_send_direct_write; 93 | if (lo->transfer != transfer_none) { 94 | page = alloc_page(GFP_NOIO | __GFP_HIGHMEM); 95 | @@ -376,7 +383,7 @@ static int lo_send(struct loop_device *lo, struct bio *bio, loff_t pos) 96 | break; 97 | } 98 | 99 | - ret = do_lo_send(lo, vec, fpos, page); 100 | + ret = do_lo_send(lo, lo_file, vec, fpos, page); 101 | if (ret < 0) 102 | break; 103 | 104 | @@ -450,8 +457,8 @@ lo_direct_splice_actor(struct pipe_inode_info *pipe, struct splice_desc *sd) 105 | } 106 | 107 | static int 108 | -do_lo_receive(struct loop_device *lo, 109 | - struct bio_vec *bvec, int bsize, loff_t pos) 110 | +do_lo_receive(struct loop_device *lo, struct lo_file *lo_file, 111 | + struct bio_vec *bvec, loff_t pos) 112 | { 113 | struct lo_read_data cookie; 114 | struct splice_desc sd; 115 | @@ -461,7 +468,7 @@ do_lo_receive(struct loop_device *lo, 116 | cookie.lo = lo; 117 | cookie.page = bvec->bv_page; 118 | cookie.offset = bvec->bv_offset; 119 | - cookie.bsize = bsize; 120 | + cookie.bsize = lo_file->blocksize; 121 | 122 | sd.len = 0; 123 | sd.total_len = bvec->bv_len; 124 | @@ -469,7 +476,7 @@ do_lo_receive(struct loop_device *lo, 125 | sd.pos = pos; 126 | sd.u.data = &cookie; 127 | 128 | - file = lo->lo_file.file; 129 | + file = lo_file->file; 130 | retval = splice_direct_to_actor(file, &sd, lo_direct_splice_actor); 131 | 132 | if (retval < 0) 133 | @@ -479,7 +486,8 @@ do_lo_receive(struct loop_device *lo, 134 | } 135 | 136 | static int 137 | -lo_receive(struct loop_device *lo, struct bio *bio, int bsize, loff_t pos) 138 | +lo_receive(struct loop_device *lo, struct lo_file *lo_file, 139 | + struct bio *bio, loff_t pos) 140 | { 141 | loff_t fpos; 142 | struct bio_vec *bvec, *vec, ovec, rvec; 143 | @@ -496,7 +504,7 @@ lo_receive(struct loop_device *lo, struct bio *bio, int bsize, loff_t pos) 144 | break; 145 | } 146 | 147 | - ret = do_lo_receive(lo, vec, bsize, fpos); 148 | + ret = do_lo_receive(lo, lo_file, vec, fpos); 149 | if (ret < 0) 150 | break; 151 | 152 | @@ -534,7 +542,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) 153 | } 154 | } 155 | 156 | - ret = lo_send(lo, bio, pos); 157 | + ret = lo_send(lo, &lo->lo_file, bio, pos); 158 | 159 | ret = lo->lo_parser->flush(lo, lo->lo_parser_priv); 160 | if (unlikely(ret)) { 161 | @@ -548,7 +556,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) 162 | ret = -EIO; 163 | } 164 | } else 165 | - ret = lo_receive(lo, bio, lo->lo_file.blocksize, pos); 166 | + ret = lo_receive(lo, &lo->lo_file, bio, pos); 167 | 168 | out: 169 | return ret; 170 | -- 171 | 1.7.0.4 172 | 173 | -------------------------------------------------------------------------------- /linux/3.2/kgdb/0007-x86-NMI-Be-smarter-about-invoking-panic-inside-NMI-h.patch: -------------------------------------------------------------------------------- 1 | From a75e1068b52f1cdcdcc24f16c59dbe2682cb280b Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Thu, 1 Mar 2012 02:27:02 -0500 4 | Subject: [PATCH 7/7] x86 NMI: Be smarter about invoking panic() inside NMI 5 | handler. 6 | 7 | If two (or more) unknown NMIs arrive on different CPUs, there 8 | is a large chance both CPUs will wind up inside panic(). This 9 | is fine, unless you want to enter KDB - KDB cannot round up 10 | all CPUs, because some of them are stuck inside 11 | panic_smp_self_stop with NMI latched. This is 12 | easy to replicate with QEMU. Boot with -smp 4 and 13 | send NMI using the monitor. 14 | 15 | Solution for this - attempt to enter panic() from NMI 16 | handler. If panic() is already active in the system, 17 | just exit out of the NMI handler. This lets KDB round 18 | up CPUs. 19 | 20 | Signed-off-by: Andrei Warkentin 21 | --- 22 | arch/x86/kernel/nmi.c | 6 ++-- 23 | include/linux/kernel.h | 1 + 24 | kernel/panic.c | 82 +++++++++++++++++++++++++++++++++++++----------- 25 | 3 files changed, 67 insertions(+), 22 deletions(-) 26 | 27 | diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c 28 | index 47acaf3..9e6a69a 100644 29 | --- a/arch/x86/kernel/nmi.c 30 | +++ b/arch/x86/kernel/nmi.c 31 | @@ -227,7 +227,7 @@ pci_serr_error(unsigned char reason, struct pt_regs *regs) 32 | #endif 33 | 34 | if (panic_on_unrecovered_nmi) 35 | - panic("NMI: Not continuing"); 36 | + try_panic("NMI: Not continuing"); 37 | 38 | pr_emerg("Dazed and confused, but trying to continue\n"); 39 | 40 | @@ -247,7 +247,7 @@ io_check_error(unsigned char reason, struct pt_regs *regs) 41 | show_registers(regs); 42 | 43 | if (panic_on_io_nmi) 44 | - panic("NMI IOCK error: Not continuing"); 45 | + try_panic("NMI IOCK error: Not continuing"); 46 | 47 | /* Re-enable the IOCK line, wait for a few seconds */ 48 | reason = (reason & NMI_REASON_CLEAR_MASK) | NMI_REASON_CLEAR_IOCHK; 49 | @@ -297,7 +297,7 @@ unknown_nmi_error(unsigned char reason, struct pt_regs *regs) 50 | 51 | pr_emerg("Do you have a strange power saving mode enabled?\n"); 52 | if (unknown_nmi_panic || panic_on_unrecovered_nmi) 53 | - panic("NMI: Not continuing"); 54 | + try_panic("NMI: Not continuing"); 55 | 56 | pr_emerg("Dazed and confused, but trying to continue\n"); 57 | } 58 | diff --git a/include/linux/kernel.h b/include/linux/kernel.h 59 | index 01ab0aa..82983f9 100644 60 | --- a/include/linux/kernel.h 61 | +++ b/include/linux/kernel.h 62 | @@ -188,6 +188,7 @@ extern long (*panic_blink)(int state); 63 | __printf(1, 2) 64 | void panic(const char *fmt, ...) 65 | __noreturn __cold; 66 | +void try_panic(const char *fmt, ...) __cold; 67 | extern void oops_enter(void); 68 | extern void oops_exit(void); 69 | void print_oops_end_marker(void); 70 | diff --git a/kernel/panic.c b/kernel/panic.c 71 | index 80aed44..9c88b49 100644 72 | --- a/kernel/panic.c 73 | +++ b/kernel/panic.c 74 | @@ -58,40 +58,26 @@ void __weak panic_smp_self_stop(void) 75 | cpu_relax(); 76 | } 77 | 78 | +static DEFINE_SPINLOCK(panic_lock); 79 | + 80 | /** 81 | - * panic - halt the system 82 | + * __panic - halt the system 83 | * @fmt: The text string to print 84 | + * @args: va_list associated with fmt 85 | * 86 | * Display a message, then perform cleanups. 87 | * 88 | * This function never returns. 89 | */ 90 | -void panic(const char *fmt, ...) 91 | +void __noreturn __cold __panic(const char *fmt, va_list args) 92 | { 93 | - static DEFINE_SPINLOCK(panic_lock); 94 | static char buf[1024]; 95 | - va_list args; 96 | long i, i_next = 0; 97 | int state = 0; 98 | 99 | - /* 100 | - * It's possible to come here directly from a panic-assertion and 101 | - * not have preempt disabled. Some functions called from here want 102 | - * preempt to be disabled. No point enabling it later though... 103 | - * 104 | - * Only one CPU is allowed to execute the panic code from here. For 105 | - * multiple parallel invocations of panic, all other CPUs either 106 | - * stop themself or will wait until they are stopped by the 1st CPU 107 | - * with smp_send_stop(). 108 | - */ 109 | - if (!spin_trylock(&panic_lock)) 110 | - panic_smp_self_stop(); 111 | - 112 | console_verbose(); 113 | bust_spinlocks(1); 114 | - va_start(args, fmt); 115 | vsnprintf(buf, sizeof(buf), fmt, args); 116 | - va_end(args); 117 | printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf); 118 | #ifdef CONFIG_DEBUG_BUGVERBOSE 119 | /* 120 | @@ -175,8 +161,66 @@ void panic(const char *fmt, ...) 121 | } 122 | } 123 | 124 | +/** 125 | + * panic - halt the system 126 | + * @fmt: The text string to print 127 | + * 128 | + * Display a message, then perform cleanups. 129 | + * 130 | + * This function never returns. 131 | + */ 132 | +void panic(const char *fmt, ...) 133 | +{ 134 | + va_list args; 135 | + 136 | + /* 137 | + * It's possible to come here directly from a panic-assertion and 138 | + * not have preempt disabled. Some functions called from here want 139 | + * preempt to be disabled. No point enabling it later though... 140 | + * 141 | + * Only one CPU is allowed to execute the panic code from here. For 142 | + * multiple parallel invocations of panic, all other CPUs either 143 | + * stop themself or will wait until they are stopped by the 1st CPU 144 | + * with smp_send_stop(). 145 | + */ 146 | + if (!spin_trylock(&panic_lock)) 147 | + panic_smp_self_stop(); 148 | + 149 | + va_start(args, fmt); 150 | + __panic(fmt, args); 151 | +} 152 | + 153 | EXPORT_SYMBOL(panic); 154 | 155 | +/** 156 | + * try_panic - halt the system, unless 157 | + * another panic is in progress 158 | + * @fmt: The text string to print 159 | + * 160 | + * Display a message, then perform cleanups. 161 | + * 162 | + * This function retuns if panic_lock is already taken. 163 | + * It is meant to be used in places which can be invoked 164 | + * concurrently on several CPUs, but where its undesired 165 | + * for the CPU to become wedged if it cannot take 166 | + * the panic lock - for example, doing so inside an 167 | + * NMI will prevent KDB from working if it's running 168 | + * due to an unknown broadcast NMI (won't be able to 169 | + * roundup using NMI, since the other CPU is spinning 170 | + * inside panic_smp_self_stop with NMI latched). 171 | + */ 172 | +void try_panic(const char *fmt, ...) 173 | +{ 174 | + va_list args; 175 | + 176 | + if (!spin_trylock(&panic_lock)) 177 | + return; 178 | + 179 | + va_start(args, fmt); 180 | + __panic(fmt, args); 181 | +} 182 | + 183 | +EXPORT_SYMBOL(try_panic); 184 | 185 | struct tnt { 186 | u8 bit; 187 | -- 188 | 1.7.9.2 189 | 190 | -------------------------------------------------------------------------------- /qemu/0002-qemu-handle-tb_gen_code-getting-called-for-unmapped-.patch: -------------------------------------------------------------------------------- 1 | From 2dfb4f72a7bccdcfdd6a853b0a9e35fe5a2e0c2e Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sat, 22 Mar 2014 03:34:49 -0400 4 | Subject: [PATCH 2/3] qemu: handle tb_gen_code getting called for unmapped pc 5 | 6 | If we try executing code that is in an unreadable page 7 | back out of the cpu loop before sending signal. 8 | 9 | Before we'd end up trying accessing directly, which 10 | would find us trying to inject a signal while holding 11 | the tcg_ctx.tb_ctx.tb_lock. 12 | 13 | i.e. after a SIGSEGV here: 14 | 15 | 0 disas_a64_insn (s=0x7fffffffdc40, env=) at /target-arm/translate-a64.c:8972 16 | 1 gen_intermediate_code_internal_a64 (cpu=cpu@entry=0x62532200, tb=tb@entry=0x7ffff440b120, search_pc=search_pc@entry=false) at /target-arm/translate-a64.c:9097 17 | 2 0x00000000600d76e5 in gen_intermediate_code_internal (search_pc=false, tb=0x7ffff440b120, cpu=0x62532200) at /target-arm/translate.c:10629 18 | 3 gen_intermediate_code (env=env@entry=0x6253a468, tb=tb@entry=0x7ffff440b120) at /target-arm/translate.c:10904 19 | 4 0x00000000600e4851 in cpu_arm_gen_code (env=env@entry=0x6253a468, tb=tb@entry=0x7ffff440b120, gen_code_size_ptr=gen_code_size_ptr@entry=0x7fffffffdd64) at /translate-all.c:159 20 | 5 0x00000000600e5152 in tb_gen_code (cpu=cpu@entry=0x62532200, pc=pc@entry=4820992, cs_base=cs_base@entry=0, flags=, cflags=cflags@entry=0) at /translate-all.c:973 21 | 6 0x0000000060040e7a in tb_find_slow (flags=, pc=4820992, env=0x6253a468, cs_base=) at /cpu-exec.c:162 22 | 7 tb_find_fast (env=0x6253a468) at /cpu-exec.c:193 23 | 8 cpu_arm_exec (env=env@entry=0x6253a468) at /cpu-exec.c:611 24 | 9 0x000000006005ad2c in cpu_loop (env=env@entry=0x6253a468) at /linux-user/main.c:1015 25 | 10 0x0000000060004dd1 in main (argc=1, argv=, envp=) at /linux-user/main.c:4392 26 | 27 | We deadlock here: 28 | 29 | 0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:132 30 | 1 0x000000006012991d in _L_lock_858 () 31 | 2 0x000000006012978a in __pthread_mutex_lock (mutex=0x604ffa98 ) at pthread_mutex_lock.c:61 32 | 3 0x0000000060040bfd in cpu_arm_exec (env=env@entry=0x6253a228) at /cpu-exec.c:610 33 | 4 0x000000006005ad2c in cpu_loop (env=env@entry=0x6253a228) at /linux-user/main.c:1015 34 | 5 0x0000000060004dd1 in main (argc=1, argv=, envp=) at /linux-user/main.c:4392 35 | 36 | AArch64 implementation for the signal delivery part. 37 | 38 | Signed-off-by: Andrei Warkentin 39 | --- 40 | cpu-exec.c | 14 ++++++++++++++ 41 | include/exec/cpu-defs.h | 1 + 42 | linux-user/main.c | 3 +++ 43 | translate-all.c | 20 ++++++++++++++++++++ 44 | 4 files changed, 38 insertions(+), 0 deletions(-) 45 | 46 | diff --git a/cpu-exec.c b/cpu-exec.c 47 | index 0914d3c..be063a9 100644 48 | --- a/cpu-exec.c 49 | +++ b/cpu-exec.c 50 | @@ -103,6 +103,11 @@ static void cpu_exec_nocache(CPUArchState *env, int max_cycles, 51 | 52 | tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, orig_tb->flags, 53 | max_cycles); 54 | + if (!tb) { 55 | + cpu->exception_index = EXCP_TB_EFAULT; 56 | + cpu_loop_exit(cpu); 57 | + } 58 | + 59 | cpu->current_tb = tb; 60 | /* execute the generated code */ 61 | cpu_tb_exec(cpu, tb->tc_ptr); 62 | @@ -155,6 +160,9 @@ static TranslationBlock *tb_find_slow(CPUArchState *env, 63 | not_found: 64 | /* if no translated code available, then translate it now */ 65 | tb = tb_gen_code(cpu, pc, cs_base, flags, 0); 66 | + if (!tb) { 67 | + return NULL; 68 | + } 69 | 70 | found: 71 | /* Move the last found TB to the head of the list */ 72 | @@ -601,6 +609,12 @@ int cpu_exec(CPUArchState *env) 73 | } 74 | spin_lock(&tcg_ctx.tb_ctx.tb_lock); 75 | tb = tb_find_fast(env); 76 | + if (!tb) { 77 | + spin_unlock(&tcg_ctx.tb_ctx.tb_lock); 78 | + cpu->exception_index = EXCP_TB_EFAULT; 79 | + cpu_loop_exit(cpu); 80 | + } 81 | + 82 | /* Note: we do it here to avoid a gcc bug on Mac OS X when 83 | doing it in tb_find_slow */ 84 | if (tcg_ctx.tb_ctx.tb_invalidated_flag) { 85 | diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h 86 | index 2dd6206..dbeb8b5 100644 87 | --- a/include/exec/cpu-defs.h 88 | +++ b/include/exec/cpu-defs.h 89 | @@ -59,6 +59,7 @@ typedef uint64_t target_ulong; 90 | #define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */ 91 | #define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */ 92 | #define EXCP_YIELD 0x10004 /* cpu wants to yield timeslice to another */ 93 | +#define EXCP_TB_EFAULT 0x10005 /* tb_gen_code translates a page with no perms. */ 94 | 95 | /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for 96 | addresses on the same page. The top bits are the same. This allows 97 | diff --git a/linux-user/main.c b/linux-user/main.c 98 | index d03ad3a..ebf68b3 100644 99 | --- a/linux-user/main.c 100 | +++ b/linux-user/main.c 101 | @@ -1037,6 +1037,9 @@ void cpu_loop(CPUARMState *env) 102 | info._sifields._sigfault._addr = env->pc; 103 | queue_signal(env, info.si_signo, &info); 104 | break; 105 | + case EXCP_TB_EFAULT: 106 | + addr = env->pc; 107 | + goto do_segv; 108 | case EXCP_PREFETCH_ABORT: 109 | addr = env->cp15.c6_insn; 110 | goto do_segv; 111 | diff --git a/translate-all.c b/translate-all.c 112 | index 5759974..2ea1557 100644 113 | --- a/translate-all.c 114 | +++ b/translate-all.c 115 | @@ -948,8 +948,28 @@ TranslationBlock *tb_gen_code(CPUState *cpu, 116 | tb_page_addr_t phys_pc, phys_page2; 117 | target_ulong virt_page2; 118 | int code_gen_size; 119 | + PageDesc *p; 120 | 121 | phys_pc = get_page_addr_code(env, pc); 122 | + p = page_find(phys_pc >> TARGET_PAGE_BITS); 123 | + if (!p || 124 | + (p->flags == 0) || 125 | + (p->flags == PAGE_VALID)) { 126 | + 127 | + /* 128 | + * We don't check for PROT_READ/PROT_EXEC. On some 129 | + * archtitectures, PROT_WRITE implies read, yet others 130 | + * PROT_EXEC implies PROT_READ or vice versa. Assume 131 | + * if there are any permissions, then they are reasonable 132 | + * enough. 133 | + * 134 | + * If this ends up being too lax, and we can still catch 135 | + * a signal on trying to read the original code, 136 | + * we can do a read probe ("safe memory read") instead. 137 | + */ 138 | + return NULL; 139 | + } 140 | + 141 | tb = tb_alloc(pc); 142 | if (!tb) { 143 | /* flush must be done */ 144 | -- 145 | 1.7.4.1 146 | 147 | -------------------------------------------------------------------------------- /linux/3.0/mmc/0001-MMC-Safe-remove.patch: -------------------------------------------------------------------------------- 1 | Return-Path: 2 | Received: from localhost.localdomain (dyngate-ca119-13.motorola.com [144.189.96.13]) 3 | by mx.google.com with ESMTPS id f5sm1661040ybh.13.2011.04.04.12.51.03 4 | (version=TLSv1/SSLv3 cipher=OTHER); 5 | Mon, 04 Apr 2011 12:51:04 -0700 (PDT) 6 | From: Andrei Warkentin 7 | To: linux-mmc@vger.kernel.org 8 | Cc: Andrei Warkentin 9 | Subject: [RFC] MMC: Request for comments attempt at dealing with removeable suspend/resume. 10 | Date: Mon, 4 Apr 2011 15:31:09 -0500 11 | Message-Id: <1301949069-13283-1-git-send-email-andreiw@motorola.com> 12 | X-Mailer: git-send-email 1.7.0.4 13 | In-Reply-To: 14 | References: 15 | 16 | Is there any value to doing something like this in order to be able to suspend/resume 17 | with a (manually, or rootfs) mounted filesystem on mmcblk? 18 | 19 | Thoughts? 20 | 21 | Signed-off-by: Andrei Warkentin 22 | --- 23 | drivers/mmc/card/block.c | 76 +++++++++++++++++++++++++++++++++++++++++---- 24 | drivers/mmc/core/core.c | 3 +- 25 | 2 files changed, 70 insertions(+), 9 deletions(-) 26 | 27 | diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c 28 | index ee8f7a9..19eb5b6 100644 29 | --- a/drivers/mmc/card/block.c 30 | +++ b/drivers/mmc/card/block.c 31 | @@ -53,6 +53,9 @@ MODULE_ALIAS("mmc:block"); 32 | ((card)->ext_csd.rel_sectors))) 33 | 34 | static DEFINE_MUTEX(block_mutex); 35 | +static DEFINE_MUTEX(orphan_mutex); 36 | + 37 | +struct list_head orphans = LIST_HEAD_INIT(orphans); 38 | 39 | /* 40 | * The defaults come from config options but can be overriden by module 41 | @@ -77,6 +80,7 @@ struct mmc_blk_data { 42 | struct gendisk *disk; 43 | struct mmc_queue queue; 44 | struct list_head part; 45 | + struct list_head orphan; 46 | 47 | unsigned int usage; 48 | unsigned int read_only; 49 | @@ -88,6 +92,7 @@ struct mmc_blk_data { 50 | * track of the current selected device partition. 51 | */ 52 | unsigned int part_curr; 53 | + u32 raw_cid[4]; 54 | struct device_attribute force_ro; 55 | }; 56 | 57 | @@ -126,10 +131,12 @@ static void mmc_blk_put(struct mmc_blk_data *md) 58 | mutex_lock(&open_lock); 59 | md->usage--; 60 | if (md->usage == 0) { 61 | - int devidx = mmc_get_devidx(md->disk); 62 | - blk_cleanup_queue(md->queue.queue); 63 | + mutex_lock(&orphan_mutex); 64 | + list_del(&md->orphan); 65 | + mutex_unlock(&orphan_mutex); 66 | 67 | - __clear_bit(devidx, dev_use); 68 | + blk_cleanup_queue(md->queue.queue); 69 | + __clear_bit(mmc_get_devidx(md->disk), dev_use); 70 | 71 | put_disk(md->disk); 72 | kfree(md); 73 | @@ -718,6 +725,49 @@ static inline int mmc_blk_readonly(struct mmc_card *card) 74 | !(card->csd.cmdclass & CCC_BLOCK_WRITE); 75 | } 76 | 77 | +static inline struct mmc_blk_data *mmc_lookup_orphan(struct mmc_card *card, 78 | + struct device *parent, 79 | + unsigned int part_type, 80 | + sector_t size) 81 | +{ 82 | + int ret; 83 | + struct list_head *pos, *q; 84 | + struct mmc_blk_data *md; 85 | + bool found = false; 86 | + 87 | + mutex_lock(&orphan_mutex); 88 | + list_for_each_safe(pos, q, &orphans) { 89 | + md = list_entry(pos, struct mmc_blk_data, orphan); 90 | + if (!memcmp(md->raw_cid, card->raw_cid, sizeof(md->raw_cid)) && 91 | + md->part_type == part_type) { 92 | + list_del(pos); 93 | + found = true; 94 | + mmc_blk_get(md->disk); 95 | + break; 96 | + } 97 | + } 98 | + mutex_unlock(&orphan_mutex); 99 | + 100 | + if (!found) 101 | + return NULL; 102 | + 103 | + ret = mmc_init_queue(&md->queue, card, &md->lock); 104 | + if (ret) 105 | + return NULL; 106 | + 107 | + INIT_LIST_HEAD(&md->part); 108 | + md->disk->driverfs_dev = parent; 109 | + md->queue.issue_fn = mmc_blk_issue_rq; 110 | + md->queue.data = md; 111 | + md->disk->queue = md->queue.queue; 112 | + if (REL_WRITES_SUPPORTED(card)) 113 | + blk_queue_flush(md->queue.queue, REQ_FLUSH | REQ_FUA); 114 | + blk_queue_logical_block_size(md->queue.queue, 512); 115 | + set_capacity(md->disk, size); 116 | + printk("set cap to %x\n", (unsigned int) get_capacity(md->disk)); 117 | + return md; 118 | +} 119 | + 120 | static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, 121 | struct device *parent, 122 | sector_t size, 123 | @@ -752,7 +802,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, 124 | 125 | spin_lock_init(&md->lock); 126 | INIT_LIST_HEAD(&md->part); 127 | + INIT_LIST_HEAD(&md->orphan); 128 | md->usage = 1; 129 | + memcpy(md->raw_cid, card->raw_cid, sizeof(card->raw_cid)); 130 | 131 | ret = mmc_init_queue(&md->queue, card, &md->lock); 132 | if (ret) 133 | @@ -822,7 +874,9 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) 134 | size = card->csd.capacity << (card->csd.read_blkbits - 9); 135 | } 136 | 137 | - md = mmc_blk_alloc_req(card, &card->dev, size, false, NULL); 138 | + md = mmc_lookup_orphan(card, &card->dev, 0, size); 139 | + if (!md) 140 | + md = mmc_blk_alloc_req(card, &card->dev, size, false, NULL); 141 | return md; 142 | } 143 | 144 | @@ -836,8 +890,10 @@ static int mmc_blk_alloc_part(struct mmc_card *card, 145 | char cap_str[10]; 146 | struct mmc_blk_data *part_md; 147 | 148 | - part_md = mmc_blk_alloc_req(card, disk_to_dev(md->disk), size, default_ro, 149 | - subname); 150 | + part_md = mmc_lookup_orphan(card, disk_to_dev(md->disk), part_type, size); 151 | + if (!part_md) 152 | + part_md = mmc_blk_alloc_req(card, disk_to_dev(md->disk), size, 153 | + default_ro, subname); 154 | if (IS_ERR(part_md)) 155 | return PTR_ERR(part_md); 156 | part_md->part_type = part_type; 157 | @@ -906,6 +962,10 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md) 158 | 159 | /* Then flush out any already in there */ 160 | mmc_cleanup_queue(&md->queue); 161 | + 162 | + mutex_lock(&orphan_mutex); 163 | + list_add(&md->orphan, &orphans); 164 | + mutex_unlock(&orphan_mutex); 165 | mmc_blk_put(md); 166 | } 167 | } 168 | @@ -933,8 +993,10 @@ static int mmc_add_disk(struct mmc_blk_data *md) 169 | md->force_ro.attr.name = "force_ro"; 170 | md->force_ro.attr.mode = S_IRUGO | S_IWUSR; 171 | ret = device_create_file(disk_to_dev(md->disk), &md->force_ro); 172 | - if (ret) 173 | + if (ret) { 174 | del_gendisk(md->disk); 175 | + return ret; 176 | + } 177 | 178 | return ret; 179 | } 180 | diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c 181 | index 85ef72c..87c4af7 100644 182 | --- a/drivers/mmc/core/core.c 183 | +++ b/drivers/mmc/core/core.c 184 | @@ -1823,11 +1823,10 @@ int mmc_pm_notify(struct notifier_block *notify_block, 185 | if (!host->bus_ops || host->bus_ops->suspend) 186 | break; 187 | 188 | - mmc_claim_host(host); 189 | - 190 | if (host->bus_ops->remove) 191 | host->bus_ops->remove(host); 192 | 193 | + mmc_claim_host(host); 194 | mmc_detach_bus(host); 195 | mmc_release_host(host); 196 | host->pm_flags = 0; 197 | -- 198 | 1.7.0.4 -------------------------------------------------------------------------------- /uefi/GSoC2012/0002-UefiCpuPkg-MP-Support-WIP.patch: -------------------------------------------------------------------------------- 1 | From eda209f890a5308aae8e941afe5f7290972bd6ac Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Sat, 21 Apr 2012 00:17:55 -0400 4 | Subject: [PATCH 2/5] UefiCpuPkg: MP Support WIP. 5 | 6 | WIP. 7 | 8 | Signed-off-by: Andrei Warkentin 9 | --- 10 | UefiCpuPkg/CpuDxe/CpuDxe.c | 1 + 11 | UefiCpuPkg/CpuDxe/CpuDxe.h | 3 + 12 | UefiCpuPkg/CpuDxe/CpuDxe.inf | 2 + 13 | UefiCpuPkg/CpuDxe/MpService.c | 130 ++++++++++++++++++++++++++++++++++++++++++ 14 | 4 files changed, 136 insertions(+) 15 | create mode 100644 UefiCpuPkg/CpuDxe/MpService.c 16 | 17 | diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c 18 | index 89dd2df..e1f24f0 100644 19 | --- a/UefiCpuPkg/CpuDxe/CpuDxe.c 20 | +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c 21 | @@ -1268,6 +1268,7 @@ InitializeCpu ( 22 | Status = gBS->InstallMultipleProtocolInterfaces ( 23 | &mCpuHandle, 24 | &gEfiCpuArchProtocolGuid, &gCpu, 25 | + &gEfiMpServiceProtocolGuid, &gMPS, 26 | NULL 27 | ); 28 | ASSERT_EFI_ERROR (Status); 29 | diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h 30 | index 6d0d83b..e148f66 100644 31 | --- a/UefiCpuPkg/CpuDxe/CpuDxe.h 32 | +++ b/UefiCpuPkg/CpuDxe/CpuDxe.h 33 | @@ -29,6 +29,7 @@ 34 | #include 35 | #include 36 | #include 37 | +#include 38 | 39 | // 40 | // 41 | @@ -286,5 +287,7 @@ RestoreInterruptDescriptorTableHandlerAddress ( 42 | IN UINTN Index 43 | ); 44 | 45 | +extern EFI_MP_SERVICES_PROTOCOL gMPS; 46 | + 47 | #endif 48 | 49 | diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf 50 | index 0c70b32..4b65899 100644 51 | --- a/UefiCpuPkg/CpuDxe/CpuDxe.inf 52 | +++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf 53 | @@ -42,6 +42,7 @@ 54 | CpuDxe.c 55 | CpuDxe.h 56 | CpuGdt.c 57 | + MpService.c 58 | 59 | Ia32/IvtAsm.asm | MSFT 60 | Ia32/IvtAsm.asm | INTEL 61 | @@ -59,6 +60,7 @@ 62 | 63 | [Protocols] 64 | gEfiCpuArchProtocolGuid 65 | + gEfiMpServiceProtocolGuid 66 | 67 | [Guids] 68 | gIdleLoopEventGuid ## CONSUMES ## GUID 69 | diff --git a/UefiCpuPkg/CpuDxe/MpService.c b/UefiCpuPkg/CpuDxe/MpService.c 70 | new file mode 100644 71 | index 0000000..6c2f7e3 72 | --- /dev/null 73 | +++ b/UefiCpuPkg/CpuDxe/MpService.c 74 | @@ -0,0 +1,130 @@ 75 | +/** @file 76 | + CPU MP support. 77 | + 78 | + Copyright (c) 2012, Andrei Warkentin 79 | + This program and the accompanying materials 80 | + are licensed and made available under the terms and conditions of the BSD License 81 | + which accompanies this distribution. The full text of the license may be found at 82 | + http://opensource.org/licenses/bsd-license.php 83 | + 84 | + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 85 | + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 86 | + 87 | +**/ 88 | + 89 | +#include "CpuDxe.h" 90 | + 91 | +EFI_STATUS 92 | +EFIAPI MpGetNumberOfProcessors( 93 | + IN EFI_MP_SERVICES_PROTOCOL *This, 94 | + OUT UINTN *NumberOfProcessors, 95 | + OUT UINTN *NumberOfEnabledProcessors 96 | + ) 97 | +{ 98 | + if (NumberOfProcessors == NULL || 99 | + NumberOfEnabledProcessors == NULL) { 100 | + return EFI_INVALID_PARAMETER; 101 | + } 102 | + 103 | + *NumberOfProcessors = 1; 104 | + *NumberOfEnabledProcessors = 1; 105 | + return EFI_SUCCESS; 106 | +} 107 | + 108 | + 109 | +EFI_STATUS 110 | +EFIAPI MpGetProcessorInfo( 111 | + IN EFI_MP_SERVICES_PROTOCOL *This, 112 | + IN UINTN ProcessorNumber, 113 | + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer 114 | + ) 115 | +{ 116 | + return EFI_UNSUPPORTED; 117 | +} 118 | + 119 | + 120 | +EFI_STATUS 121 | +EFIAPI MpStartupAllAPs( 122 | + IN EFI_MP_SERVICES_PROTOCOL *This, 123 | + IN EFI_AP_PROCEDURE Procedure, 124 | + IN BOOLEAN SingleThread, 125 | + IN EFI_EVENT WaitEvent OPTIONAL, 126 | + IN UINTN TimeoutInMicroSeconds, 127 | + IN VOID *ProcedureArgument OPTIONAL, 128 | + OUT UINTN **FailedCpuList OPTIONAL 129 | + ) 130 | +{ 131 | + return EFI_NOT_STARTED; 132 | +} 133 | + 134 | + 135 | +EFI_STATUS 136 | +EFIAPI MpStartupThisAP( 137 | + IN EFI_MP_SERVICES_PROTOCOL *This, 138 | + IN EFI_AP_PROCEDURE Procedure, 139 | + IN UINTN ProcessorNumber, 140 | + IN EFI_EVENT WaitEvent OPTIONAL, 141 | + IN UINTN TimeoutInMicroseconds, 142 | + IN VOID *ProcedureArgument OPTIONAL, 143 | + OUT BOOLEAN *Finished OPTIONAL 144 | + ) 145 | +{ 146 | + if (ProcessorNumber == 0) { 147 | + return EFI_INVALID_PARAMETER; 148 | + } 149 | + 150 | + return EFI_NOT_FOUND; 151 | +} 152 | + 153 | + 154 | +EFI_STATUS 155 | +EFIAPI MpSwitchBSP( 156 | + IN EFI_MP_SERVICES_PROTOCOL *This, 157 | + IN UINTN ProcessorNumber, 158 | + IN BOOLEAN EnableOldBSP 159 | + ) 160 | +{ 161 | + if (ProcessorNumber == 0) { 162 | + return EFI_INVALID_PARAMETER; 163 | + } 164 | + 165 | + return EFI_NOT_FOUND; 166 | +} 167 | + 168 | + 169 | +EFI_STATUS 170 | +EFIAPI MpEnableDisableAP( 171 | + IN EFI_MP_SERVICES_PROTOCOL *This, 172 | + IN UINTN ProcessorNumber, 173 | + IN BOOLEAN EnableAP, 174 | + IN UINT32 *HealthFlag OPTIONAL 175 | + ) 176 | +{ 177 | + if (ProcessorNumber == 0) { 178 | + return EFI_INVALID_PARAMETER; 179 | + } 180 | + 181 | + return EFI_NOT_FOUND; 182 | +} 183 | + 184 | + 185 | +EFI_STATUS 186 | +EFIAPI MpWhoAmI( 187 | + IN EFI_MP_SERVICES_PROTOCOL *This, 188 | + OUT UINTN *ProcessorNumber 189 | + ) 190 | +{ 191 | + *ProcessorNumber = 1; 192 | + return EFI_SUCCESS; 193 | +} 194 | + 195 | + 196 | +EFI_MP_SERVICES_PROTOCOL gMPS = { 197 | + MpGetNumberOfProcessors, 198 | + MpGetProcessorInfo, 199 | + MpStartupAllAPs, 200 | + MpStartupThisAP, 201 | + MpSwitchBSP, 202 | + MpEnableDisableAP, 203 | + MpWhoAmI 204 | +}; 205 | -- 206 | 2.5.3 207 | 208 | -------------------------------------------------------------------------------- /linux/3.2/kgdb/0002-KDB-Overide-LINES-for-custom-commands.patch: -------------------------------------------------------------------------------- 1 | From 7d831f7a496660d2c07c7a9d101b718e5f75cfcb Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Fri, 17 Feb 2012 20:59:04 -0500 4 | Subject: [PATCH 2/7] KDB: Overide LINES for custom commands. 5 | 6 | Commands like dumpall define some maximum 7 | LINES, which as a default might make sense, 8 | when run over serial connection. 9 | 10 | However, for vga/kbd use, you want to 11 | have the ability to override any custom 12 | command's attempt to set LINES, otherwise 13 | you'll never see most of the output. 14 | 15 | This adds a '-b' option to all commands 16 | defined with defcmd, which forces the current 17 | LINES to be used and all attempts to override 18 | it inside the custom command be ignored. 19 | 20 | While at it, make kdb_defcmd more robust. It 21 | was not checking the result of strdup. 22 | 23 | Signed-off-by: Andrei Warkentin 24 | --- 25 | kernel/debug/kdb/kdb_main.c | 42 ++++++++++++++++++++++++++++++++++++---- 26 | kernel/debug/kdb/kdb_private.h | 3 +++ 27 | kernel/debug/kdb/kdb_support.c | 25 +++++++++++++++++++----- 28 | 3 files changed, 61 insertions(+), 9 deletions(-) 29 | 30 | diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c 31 | index ea143ce..7d57d2e 100644 32 | --- a/kernel/debug/kdb/kdb_main.c 33 | +++ b/kernel/debug/kdb/kdb_main.c 34 | @@ -391,6 +391,13 @@ int kdb_set(int argc, const char **argv) 35 | int lines; 36 | char *cp; 37 | 38 | + /* 39 | + * We are running a custom command, 40 | + * and want to use current limit on 41 | + * lines displayed. 42 | + */ 43 | + if (KDB_STATE(RO_LINES)) 44 | + return 0; 45 | lines = simple_strtol(argv[2], &cp, 0); 46 | if (cp == argv[2]) { 47 | kdb_printf("kdb: illegal LINES value '%s'\n", 48 | @@ -674,6 +681,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0) 49 | 50 | static int kdb_defcmd(int argc, const char **argv) 51 | { 52 | + static char usage[] = " [-b]"; 53 | struct defcmd_set *save_defcmd_set = defcmd_set, *s; 54 | if (defcmd_in_progress) { 55 | kdb_printf("kdb: nested defcmd detected, assuming missing " 56 | @@ -703,13 +711,24 @@ static int kdb_defcmd(int argc, const char **argv) 57 | } 58 | memcpy(defcmd_set, save_defcmd_set, 59 | defcmd_set_count * sizeof(*defcmd_set)); 60 | - kfree(save_defcmd_set); 61 | s = defcmd_set + defcmd_set_count; 62 | memset(s, 0, sizeof(*s)); 63 | s->usable = 1; 64 | s->name = kdb_strdup(argv[1], GFP_KDB); 65 | - s->usage = kdb_strdup(argv[2], GFP_KDB); 66 | + s->usage = kdb_strdup_extra(argv[2], 67 | + sizeof(usage) - 1, 68 | + GFP_KDB); 69 | s->help = kdb_strdup(argv[3], GFP_KDB); 70 | + if (!s->name || 71 | + !s->usage || 72 | + !s->help) { 73 | + kdb_printf("Could not allocate defcmd entry members for %s\n", 74 | + argv[1]); 75 | + kfree(defcmd_set); 76 | + defcmd_set = save_defcmd_set; 77 | + return KDB_NOTIMP; 78 | + } 79 | + kfree(save_defcmd_set); 80 | if (s->usage[0] == '"') { 81 | strcpy(s->usage, s->usage+1); 82 | s->usage[strlen(s->usage)-1] = '\0'; 83 | @@ -718,6 +737,15 @@ static int kdb_defcmd(int argc, const char **argv) 84 | strcpy(s->help, s->help+1); 85 | s->help[strlen(s->help)-1] = '\0'; 86 | } 87 | + 88 | + /* 89 | + * Don't print leading space before [-b] 90 | + * if usage was empty. 91 | + */ 92 | + if (s->usage[0] == '\0') 93 | + strcat(s->usage, usage + 1); 94 | + else 95 | + strcat(s->usage, usage); 96 | ++defcmd_set_count; 97 | defcmd_in_progress = 1; 98 | return 0; 99 | @@ -739,8 +767,9 @@ static int kdb_exec_defcmd(int argc, const char **argv) 100 | struct defcmd_set *s; 101 | int ret = 0; 102 | 103 | - if (argc != 0) 104 | + if (argc > 1) 105 | return KDB_ARGCOUNT; 106 | + 107 | for (s = defcmd_set, i = 0; i < defcmd_set_count; ++i, ++s) { 108 | if (strcmp(s->name, argv[0]) == 0) 109 | break; 110 | @@ -751,8 +780,10 @@ static int kdb_exec_defcmd(int argc, const char **argv) 111 | return KDB_NOTIMP; 112 | } 113 | 114 | - /* command might have overridden LINES */ 115 | + if (!strcmp(argv[1], "-b")) 116 | + KDB_STATE_SET(RO_LINES); 117 | oldlines = kdb_lines; 118 | + 119 | for (i = 0; i < s->count; ++i) { 120 | /* Recursive use of kdb_parse, do not use argv after 121 | * this point */ 122 | @@ -762,7 +793,10 @@ static int kdb_exec_defcmd(int argc, const char **argv) 123 | if (ret) 124 | break; 125 | } 126 | + 127 | + /* command might have overridden LINES */ 128 | kdb_lines = oldlines; 129 | + KDB_STATE_CLEAR(RO_LINES); 130 | return ret; 131 | } 132 | 133 | diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h 134 | index 41a221f..99ed959 100644 135 | --- a/kernel/debug/kdb/kdb_private.h 136 | +++ b/kernel/debug/kdb/kdb_private.h 137 | @@ -112,6 +112,7 @@ extern int kdbgetsymval(const char *, kdb_symtab_t *); 138 | extern int kdbnearsym(unsigned long, kdb_symtab_t *); 139 | extern void kdbnearsym_cleanup(void); 140 | extern char *kdb_strdup(const char *str, gfp_t type); 141 | +extern char *kdb_strdup_extra(const char *str, unsigned extra, gfp_t type); 142 | extern void kdb_symbol_print(unsigned long, const kdb_symtab_t *, unsigned int); 143 | 144 | /* Routine for debugging the debugger state. */ 145 | @@ -146,6 +147,8 @@ extern int kdb_state; 146 | #define KDB_STATE_KEXEC 0x00040000 /* kexec issued */ 147 | #define KDB_STATE_DOING_KGDB 0x00080000 /* kgdb enter now issued */ 148 | #define KDB_STATE_KGDB_TRANS 0x00200000 /* Transition to kgdb */ 149 | +#define KDB_STATE_RO_LINES 0x00400000 /* If LINES is allowed to be set 150 | + * within a defcmd command */ 151 | #define KDB_STATE_ARCH 0xff000000 /* Reserved for arch 152 | * specific use */ 153 | 154 | diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c 155 | index d35cc2d..e0b35b0 100644 156 | --- a/kernel/debug/kdb/kdb_support.c 157 | +++ b/kernel/debug/kdb/kdb_support.c 158 | @@ -294,6 +294,25 @@ void kdb_symbol_print(unsigned long addr, const kdb_symtab_t *symtab_p, 159 | } 160 | 161 | /* 162 | + * kdb_strdup_extra - kdb strdup-like routine, that simplifies 163 | + * strdup+strcat-like usage. 164 | + * Inputs: 165 | + * str The string to duplicate. 166 | + * extra Extra length to allocate for. 167 | + * type Flags to kmalloc for the new string. 168 | + * Returns: 169 | + * Address of the new string, NULL if storage could not be allocated. 170 | + */ 171 | +char *kdb_strdup_extra(const char *str, unsigned extra, gfp_t type) 172 | +{ 173 | + int n = strlen(str) + extra + 1; 174 | + char *s = kmalloc(n, type); 175 | + if (!s) 176 | + return NULL; 177 | + return strcpy(s, str); 178 | +} 179 | + 180 | +/* 181 | * kdb_strdup - kdb equivalent of strdup, for disasm code. 182 | * Inputs: 183 | * str The string to duplicate. 184 | @@ -306,11 +325,7 @@ void kdb_symbol_print(unsigned long addr, const kdb_symtab_t *symtab_p, 185 | */ 186 | char *kdb_strdup(const char *str, gfp_t type) 187 | { 188 | - int n = strlen(str)+1; 189 | - char *s = kmalloc(n, type); 190 | - if (!s) 191 | - return NULL; 192 | - return strcpy(s, str); 193 | + return kdb_strdup_extra(str, 0, type); 194 | } 195 | 196 | /* 197 | -- 198 | 1.7.9.2 199 | 200 | -------------------------------------------------------------------------------- /linux/3.2/kgdb/0006-KDB-Fix-usability-issues-relating-to-the-enter-key.patch: -------------------------------------------------------------------------------- 1 | From 27c8b865d7d8b19917392595ee90637009b34589 Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Tue, 28 Feb 2012 06:55:05 -0600 4 | Subject: [PATCH 6/7] KDB: Fix usability issues relating to the 'enter' key. 5 | 6 | This fixes the following problems: 7 | 1) Typematic-repeat of 'enter' gives warning message 8 | and leaks make/break if KDB exits. Repeats 9 | look something like 0x1c 0x1c .... 0x9c 10 | 2) Use of 'keypad enter' gives warning message and 11 | leaks the ENTER break/make code out if KDB exits. 12 | KP ENTER repeats look someting like 0xe0 0x1c 13 | 0xe0 0x1c ... 0xe0 0x9c. 14 | 3) Lag on the order of seconds between "break" and "make" when 15 | expecting the enter "break" code. Seen under virtualized 16 | environments such as VMware ESX. 17 | 18 | The existing special enter handler tries to glob the enter break code, 19 | but this fails if the other (KP) enter was used, or if there was a key 20 | repeat. It also fails if you mashed some keys along with enter, and 21 | you ended up with a non-enter make or non-enter break code coming 22 | after the enter make code. So first, we modify the handler to handle 23 | these cases. But performing these actions on every enter is annoying 24 | since now you can't hold ENTER down to scroll d messages in 25 | KDB. Since this special behaviour is only necessary to handle the 26 | exiting KDB ('g' + ENTER) without leaking scancodes to the OS. This 27 | cleanup needs to get executed anytime the kdb_main loop exits. 28 | 29 | Tested on QEMU. Set a bp on atkbd.c to verify no scan code was leaked. 30 | 31 | Cc: Andrei Warkentin 32 | [jason.wessel@windriver.com: move cleanup calls to kdb_main.c] 33 | Signed-off-by: Andrei Warkentin 34 | Signed-off-by: Jason Wessel 35 | --- 36 | kernel/debug/kdb/kdb_keyboard.c | 95 ++++++++++++++++++++++++++++++--------- 37 | kernel/debug/kdb/kdb_main.c | 3 ++ 38 | kernel/debug/kdb/kdb_private.h | 7 +++ 39 | 3 files changed, 83 insertions(+), 22 deletions(-) 40 | 41 | diff --git a/kernel/debug/kdb/kdb_keyboard.c b/kernel/debug/kdb/kdb_keyboard.c 42 | index 4bca634..118527a 100644 43 | --- a/kernel/debug/kdb/kdb_keyboard.c 44 | +++ b/kernel/debug/kdb/kdb_keyboard.c 45 | @@ -25,6 +25,7 @@ 46 | #define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */ 47 | 48 | static int kbd_exists; 49 | +static int kbd_last_ret; 50 | 51 | /* 52 | * Check if the keyboard controller has a keypress for us. 53 | @@ -90,8 +91,11 @@ int kdb_get_kbd_char(void) 54 | return -1; 55 | } 56 | 57 | - if ((scancode & 0x80) != 0) 58 | + if ((scancode & 0x80) != 0) { 59 | + if (scancode == 0x9c) 60 | + kbd_last_ret = 0; 61 | return -1; 62 | + } 63 | 64 | scancode &= 0x7f; 65 | 66 | @@ -178,35 +182,82 @@ int kdb_get_kbd_char(void) 67 | return -1; /* ignore unprintables */ 68 | } 69 | 70 | - if ((scancode & 0x7f) == 0x1c) { 71 | - /* 72 | - * enter key. All done. Absorb the release scancode. 73 | - */ 74 | + if (scancode == 0x1c) { 75 | + kbd_last_ret = 1; 76 | + return 13; 77 | + } 78 | + 79 | + return keychar & 0xff; 80 | +} 81 | +EXPORT_SYMBOL_GPL(kdb_get_kbd_char); 82 | + 83 | +/* 84 | + * Best effort cleanup of ENTER break codes on leaving KDB. Called on 85 | + * exiting KDB, when we know we processed an ENTER or KP ENTER scan 86 | + * code. 87 | + */ 88 | +void kdb_kbd_cleanup_state(void) 89 | +{ 90 | + int scancode, scanstatus; 91 | + 92 | + /* 93 | + * Nothing to clean up, since either 94 | + * ENTER was never pressed, or has already 95 | + * gotten cleaned up. 96 | + */ 97 | + if (!kbd_last_ret) 98 | + return; 99 | + 100 | + kbd_last_ret = 0; 101 | + /* 102 | + * Enter key. Need to absorb the break code here, lest it gets 103 | + * leaked out if we exit KDB as the result of processing 'g'. 104 | + * 105 | + * This has several interesting implications: 106 | + * + Need to handle KP ENTER, which has break code 0xe0 0x9c. 107 | + * + Need to handle repeat ENTER and repeat KP ENTER. Repeats 108 | + * only get a break code at the end of the repeated 109 | + * sequence. This means we can't propagate the repeated key 110 | + * press, and must swallow it away. 111 | + * + Need to handle possible PS/2 mouse input. 112 | + * + Need to handle mashed keys. 113 | + */ 114 | + 115 | + while (1) { 116 | while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0) 117 | - ; 118 | + cpu_relax(); 119 | 120 | /* 121 | - * Fetch the scancode 122 | + * Fetch the scancode. 123 | */ 124 | scancode = inb(KBD_DATA_REG); 125 | scanstatus = inb(KBD_STATUS_REG); 126 | 127 | - while (scanstatus & KBD_STAT_MOUSE_OBF) { 128 | - scancode = inb(KBD_DATA_REG); 129 | - scanstatus = inb(KBD_STATUS_REG); 130 | - } 131 | + /* 132 | + * Skip mouse input. 133 | + */ 134 | + if (scanstatus & KBD_STAT_MOUSE_OBF) 135 | + continue; 136 | 137 | - if (scancode != 0x9c) { 138 | - /* 139 | - * Wasn't an enter-release, why not? 140 | - */ 141 | - kdb_printf("kdb: expected enter got 0x%x status 0x%x\n", 142 | - scancode, scanstatus); 143 | - } 144 | + /* 145 | + * If we see 0xe0, this is either a break code for KP 146 | + * ENTER, or a repeat make for KP ENTER. Either way, 147 | + * since the second byte is equivalent to an ENTER, 148 | + * skip the 0xe0 and try again. 149 | + * 150 | + * If we see 0x1c, this must be a repeat ENTER or KP 151 | + * ENTER (and we swallowed 0xe0 before). Try again. 152 | + * 153 | + * We can also see make and break codes for other keys 154 | + * mashed before or after pressing ENTER. Thus, if we 155 | + * see anything other than 0x9c, we have to try again. 156 | + * 157 | + * Note, if you held some key as ENTER was depressed, 158 | + * that break code would get leaked out. 159 | + */ 160 | + if (scancode != 0x9c) 161 | + continue; 162 | 163 | - return 13; 164 | + return; 165 | } 166 | - 167 | - return keychar & 0xff; 168 | } 169 | -EXPORT_SYMBOL_GPL(kdb_get_kbd_char); 170 | diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c 171 | index 7d57d2e..07940c9 100644 172 | --- a/kernel/debug/kdb/kdb_main.c 173 | +++ b/kernel/debug/kdb/kdb_main.c 174 | @@ -1454,6 +1454,9 @@ int kdb_main_loop(kdb_reason_t reason, kdb_reason_t reason2, int error, 175 | if (KDB_STATE(DOING_SS)) 176 | KDB_STATE_CLEAR(SSBPT); 177 | 178 | + /* Clean up any keyboard devices before leaving */ 179 | + kdb_kbd_cleanup_state(); 180 | + 181 | return result; 182 | } 183 | 184 | diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h 185 | index 99ed959..5eb9062 100644 186 | --- a/kernel/debug/kdb/kdb_private.h 187 | +++ b/kernel/debug/kdb/kdb_private.h 188 | @@ -250,6 +250,13 @@ extern void debug_kusage(void); 189 | 190 | extern void kdb_set_current_task(struct task_struct *); 191 | extern struct task_struct *kdb_current_task; 192 | + 193 | +#ifdef CONFIG_KDB_KEYBOARD 194 | +extern void kdb_kbd_cleanup_state(void); 195 | +#else /* ! CONFIG_KDB_KEYBOARD */ 196 | +#define kdb_kbd_cleanup_state() 197 | +#endif /* ! CONFIG_KDB_KEYBOARD */ 198 | + 199 | #ifdef CONFIG_MODULES 200 | extern struct list_head *kdb_modules; 201 | #endif /* CONFIG_MODULES */ 202 | -- 203 | 1.7.9.2 204 | 205 | -------------------------------------------------------------------------------- /linux/3.2/block/loop/attic/0008-Loop-Allow-internal-untransformed-direct-file-I-O.patch: -------------------------------------------------------------------------------- 1 | From d42cb3048b5c612bf1dcecd3f808e669be9863ca Mon Sep 17 00:00:00 2001 2 | From: Andrei Warkentin 3 | Date: Thu, 11 Aug 2011 14:43:43 -0500 4 | Subject: [PATCH 08/18] Loop: Allow internal untransformed direct file I/O. 5 | 6 | Allow parser code to making direct file I/O using 7 | do_send and do_receive. 8 | 9 | Change-Id: I2f56fb4dc4dcb41e9e09b23e9a2da998e863103f 10 | Signed-off-by: Andrei Warkentin 11 | --- 12 | drivers/block/loop.c | 80 ++++++++++++++++++++++++++++---------------------- 13 | include/linux/loop.h | 14 +++++---- 14 | 2 files changed, 53 insertions(+), 41 deletions(-) 15 | 16 | diff --git a/drivers/block/loop.c b/drivers/block/loop.c 17 | index ecc1fc4..c423432 100644 18 | --- a/drivers/block/loop.c 19 | +++ b/drivers/block/loop.c 20 | @@ -87,6 +87,28 @@ static int part_shift; 21 | static struct loop_parser raw_parser; 22 | 23 | /* 24 | + * This is the almost do-nothing transform for regular loopback 25 | + * images and direct access to backing file from parsers. The 26 | + * backing file store linearly maps block to file position, with 27 | + * an offset supported. 28 | + */ 29 | +static struct bio_vec *transform_none(struct loop_device *lo, void *unused, 30 | + loff_t pos, loff_t *fpos, 31 | + struct bio_vec *in, 32 | + struct bio_vec *out, 33 | + struct bio_vec *rem) 34 | +{ 35 | + *fpos = pos + lo->lo_offset; 36 | + 37 | + /* Ensures "remainder" bvec is never examined in 38 | + lo_send and lo_receive. */ 39 | + rem->bv_len = 0; 40 | + 41 | + /* No need to split bvec as data is always contiguous. */ 42 | + return in; 43 | +} 44 | + 45 | +/* 46 | * Transfer functions 47 | */ 48 | static int transfer_none(struct loop_device *lo, int cmd, 49 | @@ -342,7 +364,7 @@ static int do_lo_send_write(struct loop_device *lo, 50 | } 51 | 52 | static int lo_send(struct loop_device *lo, struct lo_file *lo_file, 53 | - struct bio *bio, loff_t pos) 54 | + struct bio *bio, loff_t pos, bool direct) 55 | { 56 | int (*do_lo_send)(struct loop_device *, struct lo_file *, loop_xfer, 57 | struct bio_vec *, loff_t, struct page *page); 58 | @@ -350,11 +372,15 @@ static int lo_send(struct loop_device *lo, struct lo_file *lo_file, 59 | struct bio_vec *bvec, *vec, ovec, rvec; 60 | struct page *page = NULL; 61 | int i, ret = 0; 62 | + loop_xform transform = direct ? transform_none : 63 | + lo->lo_parser->transform; 64 | + loop_xfer transfer = direct ? transfer_none : 65 | + lo->transfer; 66 | 67 | do_lo_send = do_lo_send_aops; 68 | if (!(lo_file->flags & LO_FILE_FLAGS_USE_AOPS)) { 69 | do_lo_send = do_lo_send_direct_write; 70 | - if (lo->transfer != transfer_none) { 71 | + if (transfer != transfer_none) { 72 | page = alloc_page(GFP_NOIO | __GFP_HIGHMEM); 73 | if (unlikely(!page)) 74 | goto fail; 75 | @@ -366,15 +392,15 @@ static int lo_send(struct loop_device *lo, struct lo_file *lo_file, 76 | vec = bvec; 77 | 78 | do { 79 | - vec = lo->lo_parser->transform(lo, lo->lo_parser_priv, 80 | - pos, &fpos, 81 | - vec, &ovec, &rvec); 82 | + vec = transform(lo, lo->lo_parser_priv, 83 | + pos, &fpos, 84 | + vec, &ovec, &rvec); 85 | if (IS_ERR(vec)) { 86 | ret = PTR_ERR(vec); 87 | break; 88 | } 89 | 90 | - ret = do_lo_send(lo, lo_file, lo->transfer, vec, fpos, page); 91 | + ret = do_lo_send(lo, lo_file, transfer, vec, fpos, page); 92 | if (ret < 0) 93 | break; 94 | 95 | @@ -480,24 +506,29 @@ do_lo_receive(struct loop_device *lo, struct lo_file *lo_file, 96 | 97 | static int 98 | lo_receive(struct loop_device *lo, struct lo_file *lo_file, 99 | - struct bio *bio, loff_t pos) 100 | + struct bio *bio, loff_t pos, bool direct) 101 | { 102 | loff_t fpos; 103 | struct bio_vec *bvec, *vec, ovec, rvec; 104 | + loop_xform transform = direct ? transform_none : 105 | + lo->lo_parser->transform; 106 | + loop_xfer transfer = direct ? transfer_none : 107 | + lo->transfer; 108 | + 109 | int i, ret = 0; 110 | 111 | bio_for_each_segment(bvec, bio, i) { 112 | vec = bvec; 113 | do { 114 | - vec = lo->lo_parser->transform(lo, lo->lo_parser_priv, 115 | - pos, &fpos, 116 | - vec, &ovec, &rvec); 117 | + vec = transform(lo, lo->lo_parser_priv, 118 | + pos, &fpos, 119 | + vec, &ovec, &rvec); 120 | if (IS_ERR(vec)) { 121 | ret = PTR_ERR(vec); 122 | break; 123 | } 124 | 125 | - ret = do_lo_receive(lo, lo_file, lo->transfer, vec, fpos); 126 | + ret = do_lo_receive(lo, lo_file, transfer, vec, fpos); 127 | if (ret < 0) 128 | break; 129 | 130 | @@ -535,7 +566,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) 131 | } 132 | } 133 | 134 | - ret = lo_send(lo, &lo->lo_file, bio, pos); 135 | + ret = lo_send(lo, &lo->lo_file, bio, pos, false); 136 | 137 | ret = lo->lo_parser->flush(lo, lo->lo_parser_priv); 138 | if (unlikely(ret)) { 139 | @@ -549,7 +580,7 @@ static int do_bio_filebacked(struct loop_device *lo, struct bio *bio) 140 | ret = -EIO; 141 | } 142 | } else 143 | - ret = lo_receive(lo, &lo->lo_file, bio, pos); 144 | + ret = lo_receive(lo, &lo->lo_file, bio, pos, false); 145 | 146 | out: 147 | return ret; 148 | @@ -1742,34 +1773,13 @@ static int raw_flush(struct loop_device *lo, void *priv) 149 | return 0; 150 | } 151 | 152 | -/* 153 | - * This is the almost do-nothing transform for regular loopback 154 | - * images. The backing file store linearly maps block to file 155 | - * position, with an offset supported. 156 | - */ 157 | -static struct bio_vec *raw_transform(struct loop_device *lo, void *priv, 158 | - loff_t pos, loff_t *fpos, 159 | - struct bio_vec *in, 160 | - struct bio_vec *out, 161 | - struct bio_vec *rem) 162 | -{ 163 | - *fpos = pos + lo->lo_offset; 164 | - 165 | - /* Ensures "remainder" bvec is never examined in 166 | - lo_send and lo_receive. */ 167 | - rem->bv_len = 0; 168 | - 169 | - /* No need to split bvec as data is always contiguous. */ 170 | - return in; 171 | -} 172 | - 173 | static struct loop_parser raw_parser = 174 | { 175 | .init = raw_init, 176 | .release = raw_release, 177 | .flush = raw_flush, 178 | .size = raw_size, 179 | - .transform = raw_transform, 180 | + .transform = transform_none, 181 | .owner = THIS_MODULE 182 | }; 183 | 184 | diff --git a/include/linux/loop.h b/include/linux/loop.h 185 | index 5ff6d40..526e16d 100644 186 | --- a/include/linux/loop.h 187 | +++ b/include/linux/loop.h 188 | @@ -165,6 +165,13 @@ struct loop_func_table { 189 | int loop_register_transfer(struct loop_func_table *funcs); 190 | int loop_unregister_transfer(int number); 191 | 192 | +typedef struct bio_vec *(*loop_xform)( 193 | + struct loop_device *lo, void *priv, 194 | + loff_t pos, loff_t *fpos, 195 | + struct bio_vec *in, 196 | + struct bio_vec *out, 197 | + struct bio_vec *rem); 198 | + 199 | /* Support for loadable parser modules */ 200 | struct loop_parser { 201 | struct list_head list; 202 | @@ -172,12 +179,7 @@ struct loop_parser { 203 | void (*release)(struct loop_device *lo, void *priv); 204 | int (*flush)(struct loop_device *lo, void *priv); 205 | loff_t (*size)(struct loop_device *lo, void *priv); 206 | - struct bio_vec *(*transform)( 207 | - struct loop_device *lo, void *priv, 208 | - loff_t pos, loff_t *fpos, 209 | - struct bio_vec *in, 210 | - struct bio_vec *out, 211 | - struct bio_vec *rem); 212 | + loop_xform transform; 213 | struct module *owner; 214 | }; 215 | 216 | -- 217 | 1.7.0.4 218 | 219 | --------------------------------------------------------------------------------