Skip to content

Commit

Permalink
vtd: don't assume addresses are aligned in sync_cache
Browse files Browse the repository at this point in the history
Current code in sync_cache assume that the address passed in is
aligned to a cache line size. Fix the code to support passing in
arbitrary addresses not necessarily aligned to a cache line size.

This is part of XSA-321.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
  • Loading branch information
royger authored and jbeulich committed Jul 7, 2020
1 parent 91526b4 commit b6d9398
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions xen/drivers/passthrough/vtd/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,18 @@ static int iommus_incoherent;

static void sync_cache(const void *addr, unsigned int size)
{
int i;
static unsigned int clflush_size = 0;
static unsigned long clflush_size = 0;
const void *end = addr + size;

if ( !iommus_incoherent )
return;

if ( clflush_size == 0 )
clflush_size = get_cache_line_size();

for ( i = 0; i < size; i += clflush_size )
cacheline_flush((char *)addr + i);
addr -= (unsigned long)addr & (clflush_size - 1);
for ( ; addr < end; addr += clflush_size )
cacheline_flush((char *)addr);
}

/* Allocate page table, return its machine address */
Expand Down

0 comments on commit b6d9398

Please sign in to comment.