vpci: restrict unhandled read/write operations for guests

A guest would be able to read and write those registers which are not
emulated and have no respective vPCI handlers, so it will be possible
for it to access the hardware directly.
In order to prevent a guest from reads and writes from/to the unhandled
registers make sure only hardware domain can access the hardware directly
and restrict guests from doing so.

Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
This commit is contained in:
Oleksandr Andrushchenko authored and Jan Beulich committed 2024-02-27 14:53:50 +01:00
1 parent 4f78438b45
commit 80b0eb095a
1 file changed
+8
+8
View File
@@ -268,6 +268,10 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg,
{
uint32_t data;
/* Guest domains are not allowed to read real hardware. */
if ( !is_hardware_domain(current->domain) )
return ~(uint32_t)0;
switch ( size )
{
case 4:
@@ -311,6 +315,10 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg,
static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
uint32_t data)
{
/* Guest domains are not allowed to write real hardware. */
if ( !is_hardware_domain(current->domain) )
return;
switch ( size )
{
case 4:
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.