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=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 3D981C433E1 for ; Mon, 17 Aug 2020 10:06:36 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id E44B8206FA for ; Mon, 17 Aug 2020 10:06:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g6rxSVhS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E44B8206FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 783274C00D; Mon, 17 Aug 2020 06:06:35 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wSKL0EkBGJ8E; Mon, 17 Aug 2020 06:06:34 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8C0044C02C; Mon, 17 Aug 2020 06:06:33 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D124B4BD3E for ; Mon, 17 Aug 2020 06:06:32 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C+tDpPkEiQMf for ; Mon, 17 Aug 2020 06:06:32 -0400 (EDT) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 01A584BF11 for ; Mon, 17 Aug 2020 06:06:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597658791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PWLN6t4HhuBj0q5bBZfX8UYBQF+pOQMuL2+7lT8olrw=; b=g6rxSVhSJ698+GVSzQXBQKrw//Kkcul2RgKV+bMG6pLkadpqyAlxZPILaqCPfQF+Kycnb9 K7Hu375AbZYU5tJSMchceFtz8jurMgVt+GRTaTw03fLt8+DwWXjSPGn/ZKy6AJnavRW0xe HnpbEmQfhQNoik9ABH1KdkHsgmRLiTU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-102-veW3jxTCNwOtGkTfYVbsGg-1; Mon, 17 Aug 2020 06:06:30 -0400 X-MC-Unique: veW3jxTCNwOtGkTfYVbsGg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54771801AC5; Mon, 17 Aug 2020 10:06:29 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-130.bne.redhat.com [10.64.54.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35D3378414; Mon, 17 Aug 2020 10:06:27 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 12/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_PE_{MASK, UNMASK} hypercall Date: Mon, 17 Aug 2020 20:05:25 +1000 Message-Id: <20200817100531.83045-13-gshan@redhat.com> In-Reply-To: <20200817100531.83045-1-gshan@redhat.com> References: <20200817100531.83045-1-gshan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=gshan@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Cc: maz@kernel.org, shan.gavin@gmail.com, pbonzini@redhat.com X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu This supports SDEI_1_0_FN_SDEI_PE_{MASK, UNMASK} hypercall by adding kvm_sdei_hypercall_mask(). The status is updated accordingly so that the event targeting the masked CPU will be dropped. However, the status is never synchronized to underly firmware for the passthrou event because the event might be shared by multiple VMs. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index 1e7291acea0d..0816136e73a6 100644 --- a/arch/arm64/kvm/sdei.c +++ b/arch/arm64/kvm/sdei.c @@ -657,6 +657,26 @@ static unsigned long kvm_sdei_hypercall_route(struct kvm_vcpu *vcpu) return ret; } +static unsigned long kvm_sdei_hypercall_mask(struct kvm_vcpu *vcpu, + bool is_mask) +{ + unsigned long ret = SDEI_SUCCESS; + + /* Sanity check */ + spin_lock(&vcpu->arch.sdei_lock); + if (is_mask == vcpu->arch.sdei_masked) { + ret = SDEI_DENIED; + goto unlock; + } + + /* Update the status */ + vcpu->arch.sdei_masked = is_mask ? true : false; + +unlock: + spin_unlock(&vcpu->arch.sdei_lock); + return ret; +} + static unsigned long kvm_sdei_reset(struct kvm *kvm, unsigned int types) { struct kvm_sdei_event *e, *event = NULL; @@ -755,7 +775,11 @@ int kvm_sdei_hypercall(struct kvm_vcpu *vcpu) ret = kvm_sdei_hypercall_route(vcpu); break; case SDEI_1_0_FN_SDEI_PE_MASK: + ret = kvm_sdei_hypercall_mask(vcpu, true); + break; case SDEI_1_0_FN_SDEI_PE_UNMASK: + ret = kvm_sdei_hypercall_mask(vcpu, false); + break; case SDEI_1_0_FN_SDEI_INTERRUPT_BIND: case SDEI_1_0_FN_SDEI_INTERRUPT_RELEASE: case SDEI_1_0_FN_SDEI_PRIVATE_RESET: -- 2.23.0 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm