/* $Id: bs3-cpu-basic-2-pf.c32 64704 2016-11-17 22:51:41Z vboxsync $ */ /** @file * BS3Kit - bs3-cpu-basic-2, 32-bit C code. */ /* * Copyright (C) 2007-2016 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * The contents of this file may alternatively be used under the terms * of the Common Development and Distribution License Version 1.0 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the * VirtualBox OSE distribution, in which case the provisions of the * CDDL are applicable instead of those of the GPL. * * You may elect to license modified versions of this file under the * terms and conditions of either the GPL or the CDDL or both. */ /********************************************************************************************************************************* * Header Files * *********************************************************************************************************************************/ #include #include /********************************************************************************************************************************* * Internal Functions * *********************************************************************************************************************************/ FNBS3TESTDOMODE bs3CpuBasic2_RaiseXcpt0e_c32; BS3_DECL_CALLBACK(uint8_t) bs3CpuBasic2_RaiseXcpt0e_c32(uint8_t bMode) { void *pvTestUnaligned; uint32_t cbTestUnaligned = _8M; uint32_t cbTest; uint8_t *pbTest; uint8_t *pbAlias; int rc; /* * Allocate a some memory we can play around with, then carve a size aligned * chunk out of it so we might be able to maybe play with 2/4MB pages too. */ cbTestUnaligned = _8M * 2; while ((pvTestUnaligned = Bs3MemAlloc(BS3MEMKIND_FLAT32, cbTestUnaligned)) == NULL) { cbTestUnaligned >>= 1; if (cbTestUnaligned < _8K) { Bs3TestFailed("Failed to allocate memory to play around with\n"); return 1; } } if ((uintptr_t)pvTestUnaligned & (cbTestUnaligned - 1)) { cbTest = cbTestUnaligned >> 1; pbTest = (uint8_t *)(((uintptr_t)pvTestUnaligned + cbTest - 1) & ~(cbTest - 1)); } else { pbTest = pvTestUnaligned; cbTest = cbTestUnaligned; } /* * Alias this memory far away from where our code and data lives. */ pbAlias = (uint8_t *)UINT32_C(0xa0000000); rc = Bs3PagingAlias((uintptr_t)pbAlias, (uintptr_t)pbTest, cbTest, X86_PTE_P | X86_PTE_RW | X86_PTE_US); if (RT_SUCCESS(rc)) { void *pvPte = Bs3PagingGetPte((uintptr_t)pbAlias, NULL); if (pvPte) { Bs3TestPrintf("RaiseXcpt0e_c32: bMode=%#x/%#x cbTest=%#x pbTest=%p pbAlias=%p pvPte=%p\n", bMode, g_bBs3CurrentMode, cbTest, pbTest, pbAlias, pvPte); } else Bs3TestFailed("Bs3PagingGetPte failed!\n"); Bs3PagingUnalias((uintptr_t)pbAlias, cbTest); } else Bs3TestFailedF("Bs3PagingAlias failed! rc=%d\n", rc); Bs3MemFree(pvTestUnaligned, cbTestUnaligned); return 0; }