x86/hyperv: skeleton for L0 assisted TLB flush

Implement a basic hook for L0 assisted TLB flush. The hook needs to
check if prerequisites are met. If they are not met, it returns an error
number to fall back to native flushes.

Introduce a new variable to indicate if hypercall page is ready.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Paul Durrant <pdurrant@amazon.com>
This commit is contained in:
Wei Liu committed 2020-04-29 10:32:29 +01:00
1 parent 3d2a0c7d58
commit 75550b5fa5
4 files changed
+63

No files matched your search

+1
View File
@@ -1 +1,2 @@
obj-y += hyperv.o
obj-y += tlb.o
+17
View File
@@ -33,6 +33,8 @@ DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page);
DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist);
DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index);
static bool __read_mostly hcall_page_ready;
static uint64_t generate_guest_id(void)
{
union hv_guest_os_id id = {};
@@ -119,6 +121,8 @@ static void __init setup_hypercall_page(void)
BUG_ON(!hypercall_msr.enable);
set_fixmap_x(FIX_X_HYPERV_HCALL, mfn << PAGE_SHIFT);
hcall_page_ready = true;
}
static int setup_hypercall_pcpu_arg(void)
@@ -199,11 +203,24 @@ static void __init e820_fixup(struct e820map *e820)
panic("Unable to reserve Hyper-V hypercall range\n");
}
static int flush_tlb(const cpumask_t *mask, const void *va,
unsigned int flags)
{
if ( !(ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED) )
return -EOPNOTSUPP;
if ( !hcall_page_ready || !this_cpu(hv_input_page) )
return -ENXIO;
return hyperv_flush_tlb(mask, va, flags);
}
static const struct hypervisor_ops __initconstrel ops = {
.name = "Hyper-V",
.setup = setup,
.ap_setup = ap_setup,
.e820_fixup = e820_fixup,
.flush_tlb = flush_tlb,
};
/*
+4
View File
@@ -22,10 +22,14 @@
#ifndef __XEN_HYPERV_PRIVIATE_H__
#define __XEN_HYPERV_PRIVIATE_H__
#include <xen/cpumask.h>
#include <xen/percpu.h>
DECLARE_PER_CPU(void *, hv_input_page);
DECLARE_PER_CPU(void *, hv_vp_assist);
DECLARE_PER_CPU(unsigned int, hv_vp_index);
int hyperv_flush_tlb(const cpumask_t *mask, const void *va,
unsigned int flags);
#endif /* __XEN_HYPERV_PRIVIATE_H__ */
+41
View File
@@ -0,0 +1,41 @@
/******************************************************************************
* arch/x86/guest/hyperv/tlb.c
*
* Support for TLB management using hypercalls
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (c) 2020 Microsoft.
*/
#include <xen/cpumask.h>
#include <xen/errno.h>
#include "private.h"
int hyperv_flush_tlb(const cpumask_t *mask, const void *va,
unsigned int flags)
{
return -EOPNOTSUPP;
}
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
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.