From patchwork Sat Jan 30 13:36:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 12057217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E94DEC433DB for ; Sat, 30 Jan 2021 13:37:57 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E06E64E10 for ; Sat, 30 Jan 2021 13:37:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E06E64E10 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=tklengyel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.78873.143588 (Exim 4.92) (envelope-from ) id 1l5qRb-000390-3i; Sat, 30 Jan 2021 13:37:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 78873.143588; Sat, 30 Jan 2021 13:37:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l5qRb-00038t-0P; Sat, 30 Jan 2021 13:37:43 +0000 Received: by outflank-mailman (input) for mailman id 78873; Sat, 30 Jan 2021 13:37:41 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l5qRZ-00038o-6X for xen-devel@lists.xenproject.org; Sat, 30 Jan 2021 13:37:41 +0000 Received: from MTA-13-3.privateemail.com (unknown [198.54.118.204]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 612bfe72-8862-406d-b4b6-299f5f318828; Sat, 30 Jan 2021 13:37:38 +0000 (UTC) Received: from mta-13.privateemail.com (localhost [127.0.0.1]) by mta-13.privateemail.com (Postfix) with ESMTP id 6694B800A4; Sat, 30 Jan 2021 08:37:37 -0500 (EST) Received: from drt-xps-ubuntu.lan (unknown [10.20.151.200]) by mta-13.privateemail.com (Postfix) with ESMTPA id E25FD80099; Sat, 30 Jan 2021 13:37:35 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 612bfe72-8862-406d-b4b6-299f5f318828 From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Cc: Tamas K Lengyel , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH v8 17/16] x86/vm_event: add response flag to reset vmtrace buffer Date: Sat, 30 Jan 2021 08:36:37 -0500 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP From: Tamas K Lengyel Allow resetting the vmtrace buffer in response to a vm_event. This can be used to optimize a use-case where detecting a looped vmtrace buffer is important. Signed-off-by: Tamas K Lengyel --- This is a last minute addition to the series "acquire_resource size and external IPT monitoring" posted by Andrew, new in v8. --- xen/arch/x86/vm_event.c | 7 +++++++ xen/common/vm_event.c | 3 +++ xen/include/asm-arm/vm_event.h | 6 ++++++ xen/include/asm-x86/vm_event.h | 2 ++ xen/include/public/vm_event.h | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c index 36272e9316..8f73a73e2e 100644 --- a/xen/arch/x86/vm_event.c +++ b/xen/arch/x86/vm_event.c @@ -300,6 +300,13 @@ void vm_event_emulate_check(struct vcpu *v, vm_event_response_t *rsp) }; } +void vm_event_reset_vmtrace(struct vcpu *v) +{ +#ifdef CONFIG_HVM + hvm_vmtrace_reset(v); +#endif +} + /* * Local variables: * mode: C diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 127f2d58f1..44d542f23e 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -424,6 +424,9 @@ static int vm_event_resume(struct domain *d, struct vm_event_domain *ved) if ( rsp.flags & VM_EVENT_FLAG_GET_NEXT_INTERRUPT ) vm_event_monitor_next_interrupt(v); + if ( rsp.flags & VM_EVENT_FLAG_RESET_VMTRACE ) + vm_event_reset_vmtrace(v); + if ( rsp.flags & VM_EVENT_FLAG_VCPU_PAUSED ) vm_event_vcpu_unpause(v); } diff --git a/xen/include/asm-arm/vm_event.h b/xen/include/asm-arm/vm_event.h index 14d1d341cc..abe7db1970 100644 --- a/xen/include/asm-arm/vm_event.h +++ b/xen/include/asm-arm/vm_event.h @@ -58,4 +58,10 @@ void vm_event_sync_event(struct vcpu *v, bool value) /* Not supported on ARM. */ } +static inline +void vm_event_reset_vmtrace(struct vcpu *v) +{ + /* Not supported on ARM. */ +} + #endif /* __ASM_ARM_VM_EVENT_H__ */ diff --git a/xen/include/asm-x86/vm_event.h b/xen/include/asm-x86/vm_event.h index 785e741fba..0756124075 100644 --- a/xen/include/asm-x86/vm_event.h +++ b/xen/include/asm-x86/vm_event.h @@ -54,4 +54,6 @@ void vm_event_emulate_check(struct vcpu *v, vm_event_response_t *rsp); void vm_event_sync_event(struct vcpu *v, bool value); +void vm_event_reset_vmtrace(struct vcpu *v); + #endif /* __ASM_X86_VM_EVENT_H__ */ diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h index 147dc3ea73..36135ba4f1 100644 --- a/xen/include/public/vm_event.h +++ b/xen/include/public/vm_event.h @@ -123,6 +123,10 @@ * Set if the event comes from a nested VM and thus npt_base is valid. */ #define VM_EVENT_FLAG_NESTED_P2M (1 << 12) +/* + * Reset the vmtrace buffer (if vmtrace is enabled) + */ +#define VM_EVENT_FLAG_RESET_VMTRACE (1 << 13) /* * Reasons for the vm event request