Received: by 2002:a05:6a10:c7d3:0:0:0:0 with SMTP id h19csp597461pxy; Sat, 14 Aug 2021 17:18:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPXdbcoHeXy5/PUg34t4UADOR1uc2wkKqnOOBkhaVz+Yl8ipC/pvUIEKARVL5VEOZ2ZbUY X-Received: by 2002:a17:906:e259:: with SMTP id gq25mr9360328ejb.163.1628986699257; Sat, 14 Aug 2021 17:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628986699; cv=none; d=google.com; s=arc-20160816; b=DabbhcdM2vNRDGJQ+MT1GWGIIvMTjYd5eqG1+wGW1HEzxP7fc4+Z65m8tby1spThmV TJXsLtQSkbRTRH11wGWVp7Xvbezl3UThitSdOyP8FPjJvNEw1rye4l9we153F30kxHYt 43Z5NIpt2zpXIjGHNPPCiWGELbbHMMdiUemiCOWzxw0m6UNAq5Winn7SoUcD0D5o//xt IPThPq8WrlpLvUoTROksKh3OqzvhIDFctzziv3IwPcX8yNHU8ufVTd29zS+BCgAKQxho +nOoOMsjLv7/1rcteGinSjZ3Y8O/2OVy78QgRdyAym9KoHXz/Uj1xvuYpzflDzyd1eZg UAKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DElgAKnXxGi8roylqPYAKEl/MuVnVKXjV89e67/IzUs=; b=xxxG1Q8EjDZKoSNT4G3e6TUdrnhq7nUt+DSmL9Xfds1JzLhsXlQT4CUdyKhleCS/Xk UNf+iLTGdDwcodXC3OnjhtWlRtKvGAMAVPjZ6oS2bBtZwmfxtm89TTOk3qoDAgjbY4wJ x1ri4lO3FGyTSuGwhZweHiGN2FkYM5WNN2RHF318YarmDhrxYFMgWEaHAr0TnQpBuQ+z zLq/kdJBH1fU+qw7TOXaRYZfA6z5wHfOXnXqPuP+MgEBM0juIkOsZMQvz1RSNHcDm6QU 4zjkZnpnMdw2Uf4rUMos3p+UUDWgLlgLj4FXPWRiK6GPenppNkZ9SmNT7L2vXDVrWnSd xzUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CMBNbzrS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si7595723edj.402.2021.08.14.17.17.56; Sat, 14 Aug 2021 17:18:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CMBNbzrS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235938AbhHOAQP (ORCPT + 99 others); Sat, 14 Aug 2021 20:16:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53021 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235077AbhHOAPr (ORCPT ); Sat, 14 Aug 2021 20:15:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628986514; 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=DElgAKnXxGi8roylqPYAKEl/MuVnVKXjV89e67/IzUs=; b=CMBNbzrSvgbFLHgHqQta1SlwRmrjfrMclAJC6NOmdy8qi792ILmhVlR/fQwmY9KKH90Hmy q7yHWl6sG7YMPqM1PyqQW0CPzLIh83/nSnOEbL0UIy3tRuFgnXaCWZqNSNiW3eFBRo5RMY 85xxZoLPVVQrGCtIBwfUzemMFADcpnQ= 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-122-u7EXkTDYPOCrt3foqR6R_Q-1; Sat, 14 Aug 2021 20:15:12 -0400 X-MC-Unique: u7EXkTDYPOCrt3foqR6R_Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7452C801B3D; Sun, 15 Aug 2021 00:15:11 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-103.bne.redhat.com [10.64.54.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B44B1036D2E; Sun, 15 Aug 2021 00:15:08 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.cs.columbia.edu Cc: linux-kernel@vger.kernel.org, james.morse@arm.com, mark.rutland@arm.com, Jonathan.Cameron@huawei.com, will@kernel.org, maz@kernel.org, pbonzini@redhat.com Subject: [PATCH v4 12/21] KVM: arm64: Support SDEI_{PRIVATE, SHARED}_RESET hypercall Date: Sun, 15 Aug 2021 08:13:43 +0800 Message-Id: <20210815001352.81927-13-gshan@redhat.com> In-Reply-To: <20210815001352.81927-1-gshan@redhat.com> References: <20210815001352.81927-1-gshan@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This supports SDEI_{PRIVATE, SHARED}_RESET. They are used by the guest to purge the private or shared SDEI events, which are registered previously. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index 3fb33258b494..62efee2b67b8 100644 --- a/arch/arm64/kvm/sdei.c +++ b/arch/arm64/kvm/sdei.c @@ -582,6 +582,29 @@ static unsigned long kvm_sdei_hypercall_mask(struct kvm_vcpu *vcpu, return ret; } +static unsigned long kvm_sdei_hypercall_reset(struct kvm_vcpu *vcpu, + bool private) +{ + struct kvm *kvm = vcpu->kvm; + struct kvm_sdei_kvm *ksdei = kvm->arch.sdei; + struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei; + unsigned int mask = private ? (1 << SDEI_EVENT_TYPE_PRIVATE) : + (1 << SDEI_EVENT_TYPE_SHARED); + unsigned long ret = SDEI_SUCCESS; + + /* Sanity check */ + if (!(ksdei && vsdei)) { + ret = SDEI_NOT_SUPPORTED; + goto out; + } + + spin_lock(&ksdei->lock); + kvm_sdei_remove_kvm_events(kvm, mask, false); + spin_unlock(&ksdei->lock); +out: + return ret; +} + int kvm_sdei_hypercall(struct kvm_vcpu *vcpu) { u32 func = smccc_get_function(vcpu); @@ -626,8 +649,14 @@ int kvm_sdei_hypercall(struct kvm_vcpu *vcpu) break; case SDEI_1_0_FN_SDEI_INTERRUPT_BIND: case SDEI_1_0_FN_SDEI_INTERRUPT_RELEASE: + ret = SDEI_NOT_SUPPORTED; + break; case SDEI_1_0_FN_SDEI_PRIVATE_RESET: + ret = kvm_sdei_hypercall_reset(vcpu, true); + break; case SDEI_1_0_FN_SDEI_SHARED_RESET: + ret = kvm_sdei_hypercall_reset(vcpu, false); + break; default: ret = SDEI_NOT_SUPPORTED; } -- 2.23.0