From: Joseph C. <jos...@in...> - 2011-04-20 23:38:58
|
changeset 3af0f4081fdf in /var/www/tboot.hg details: tboot.hg?cmd=changeset;node=3af0f4081fdf description: Removed PAGE_SIZE/PAGE_SHIFT requirements from utils/* Removed NR_TXT_CONFIG_PAGES and added TXT_CONFIG_REGS_SIZE, which doesn't depend on PAGE_SIZE/PAGE_SHIFT. This makes code re-use in utils easier because not all build environments define PAGE_SIZE/PAGE_SHIFT. It is also the value that most comsumers really want. Signed-off-by: Joseph Cihula <jos...@in...> diffstat: tboot/include/txt/config_regs.h | 6 ++---- tboot/txt/mtrrs.c | 4 ++-- tboot/txt/txt.c | 2 +- utils/acminfo.c | 12 ------------ utils/parse_err.c | 12 ------------ utils/txt-stat.c | 12 ------------ 6 files changed, 5 insertions(+), 43 deletions(-) diffs (133 lines): diff -r b10898afaf24 -r 3af0f4081fdf tboot/include/txt/config_regs.h --- a/tboot/include/txt/config_regs.h Wed Apr 20 14:31:04 2011 -0700 +++ b/tboot/include/txt/config_regs.h Wed Apr 20 16:46:24 2011 -0700 @@ -43,10 +43,8 @@ #define TXT_PUB_CONFIG_REGS_BASE 0xfed30000 #define TXT_PRIV_CONFIG_REGS_BASE 0xfed20000 -/* # pages for each config regs space - used by fixmap */ -#define NR_TXT_CONFIG_PAGES ((TXT_PUB_CONFIG_REGS_BASE - \ - TXT_PRIV_CONFIG_REGS_BASE) >> \ - PAGE_SHIFT) +#define TXT_CONFIG_REGS_SIZE (TXT_PUB_CONFIG_REGS_BASE - \ + TXT_PRIV_CONFIG_REGS_BASE) /* offsets to config regs (from either public or private _BASE) */ #define TXTCR_STS 0x0000 diff -r b10898afaf24 -r 3af0f4081fdf tboot/txt/mtrrs.c --- a/tboot/txt/mtrrs.c Wed Apr 20 14:31:04 2011 -0700 +++ b/tboot/txt/mtrrs.c Wed Apr 20 16:46:24 2011 -0700 @@ -264,7 +264,7 @@ /* mmio space for TXT private config space should be UC */ if ( get_region_type(saved_state, TXT_PRIV_CONFIG_REGS_BASE, - NR_TXT_CONFIG_PAGES) + TXT_CONFIG_REGS_SIZE >> PAGE_SHIFT) != MTRR_TYPE_UNCACHABLE ) { printk("MMIO space for TXT private config space should be UC\n"); return false; @@ -272,7 +272,7 @@ /* mmio space for TXT public config space should be UC */ if ( get_region_type(saved_state, TXT_PUB_CONFIG_REGS_BASE, - NR_TXT_CONFIG_PAGES) + TXT_CONFIG_REGS_SIZE >> PAGE_SHIFT) != MTRR_TYPE_UNCACHABLE ) { printk("MMIO space for TXT public config space should be UC\n"); return false; diff -r b10898afaf24 -r 3af0f4081fdf tboot/txt/txt.c --- a/tboot/txt/txt.c Wed Apr 20 14:31:04 2011 -0700 +++ b/tboot/txt/txt.c Wed Apr 20 16:46:24 2011 -0700 @@ -744,7 +744,7 @@ /* TXT private space */ base = TXT_PRIV_CONFIG_REGS_BASE; - size = NR_TXT_CONFIG_PAGES * PAGE_SIZE; + size = TXT_CONFIG_REGS_SIZE; printk("protecting TXT Private Space (%Lx - %Lx) in e820 table\n", base, (base + size - 1)); if ( !e820_protect_region(base, size, E820_RESERVED) ) diff -r b10898afaf24 -r 3af0f4081fdf utils/acminfo.c --- a/utils/acminfo.c Wed Apr 20 14:31:04 2011 -0700 +++ b/utils/acminfo.c Wed Apr 20 16:46:24 2011 -0700 @@ -46,16 +46,6 @@ #include <sys/user.h> #include <fcntl.h> -/* tboot code assumes 4k pages */ -#ifdef PAGE_SHIFT -#undef PAGE_SHIFT -#endif -#define PAGE_SHIFT 12 -#ifdef PAGE_SIZE -#undef PAGE_SIZE -#endif -#define PAGE_SIZE (1 << PAGE_SHIFT) - #define printk printf #include "../include/config.h" #include "../include/uuid.h" @@ -104,8 +94,6 @@ #define read_pub_config_reg(reg) *(volatile uint64_t *)(pub_config_base + \ reg); -#define TXT_CONFIG_REGS_SIZE (NR_TXT_CONFIG_PAGES*PAGE_SIZE) - #define IS_INCLUDED /* prevent acmod.c #include */ #include "../tboot/txt/acmod.c" diff -r b10898afaf24 -r 3af0f4081fdf utils/parse_err.c --- a/utils/parse_err.c Wed Apr 20 14:31:04 2011 -0700 +++ b/utils/parse_err.c Wed Apr 20 16:46:24 2011 -0700 @@ -44,22 +44,10 @@ #include <sys/mman.h> #include <fcntl.h> -/* tboot code assumes 4k pages */ -#ifdef PAGE_SHIFT -#undef PAGE_SHIFT -#endif -#define PAGE_SHIFT 12 -#ifdef PAGE_SIZE -#undef PAGE_SIZE -#endif -#define PAGE_SIZE (1 << PAGE_SHIFT) - #define printk printf #include "../tboot/include/txt/config_regs.h" #include "../tboot/include/txt/errorcode.h" -#define TXT_CONFIG_REGS_SIZE (NR_TXT_CONFIG_PAGES*PAGE_SIZE) - static inline uint64_t read_txt_config_reg(void *config_regs_base, uint32_t reg) { diff -r b10898afaf24 -r 3af0f4081fdf utils/txt-stat.c --- a/utils/txt-stat.c Wed Apr 20 14:31:04 2011 -0700 +++ b/utils/txt-stat.c Wed Apr 20 16:46:24 2011 -0700 @@ -47,16 +47,6 @@ #include <sys/types.h> #include <fcntl.h> -/* tboot code assumes 4k pages */ -#ifdef PAGE_SHIFT -#undef PAGE_SHIFT -#endif -#define PAGE_SHIFT 12 -#ifdef PAGE_SIZE -#undef PAGE_SIZE -#endif -#define PAGE_SIZE (1 << PAGE_SHIFT) - #define printk printf #include "../include/config.h" #include "../include/uuid.h" @@ -71,8 +61,6 @@ #define IS_INCLUDED /* prevent #include's */ #include "../tboot/txt/heap.c" -#define TXT_CONFIG_REGS_SIZE (NR_TXT_CONFIG_PAGES*PAGE_SIZE) - static inline uint64_t read_txt_config_reg(void *config_regs_base, uint32_t reg) { |