From f92fcabba8dbb1510df6cee545b2cba5ac7e047a Mon Sep 17 00:00:00 2001 From: Naresh G Solanki Date: Mon, 2 Apr 2018 21:36:05 +0530 Subject: x86: Add function to modify CR3 register Register CR3 holds the physical address of paging-structure hierarchy. Add functions to enable read/write of this register. Change-Id: Icfd8f8e32833d2c80cefc8f930d6eedbfeb5e3ee Signed-off-by: Naresh G Solanki Reviewed-on: https://review.coreboot.org/25478 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/include/cpu/x86/cr.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/include/cpu/x86/cr.h b/src/include/cpu/x86/cr.h index dafa791213..9eb94022f5 100644 --- a/src/include/cpu/x86/cr.h +++ b/src/include/cpu/x86/cr.h @@ -59,6 +59,27 @@ static alwaysinline void write_cr0(CRx_TYPE data) ); } +static alwaysinline CRx_TYPE read_cr3(void) +{ + CRx_TYPE value; + __asm__ __volatile__ ( + "mov %%cr3, %0" + : CRx_RET(value) + : + : COMPILER_BARRIER + ); + return value; +} + +static alwaysinline void write_cr3(CRx_TYPE data) +{ + __asm__ __volatile__ ( + "mov %0, %%cr3" + : + : CRx_IN(data) + : COMPILER_BARRIER + ); +} static alwaysinline CRx_TYPE read_cr4(void) { CRx_TYPE value; -- cgit v1.2.3