From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA7A3C433EF for ; Thu, 2 Jun 2022 19:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9dfErqyA2m35Td/10O7NAKWYeiYORYAXxHOCc88xz/k=; b=DnG/YFGbBT4qvU 3U8TqkT/iC25ugUxuWMiu8x7PpAn6rio78G0urCA1tT/fkafBY95hZqGZZ2lQN34krQM3iR1oLr4c vW5mguBST8KVRw4beoUXa2kCwBpZB7G5Jv9o6jYGd6d2ssXSg2qwpbJw6osdvuonsZykARhYTQFTY /yHCOariHWYuRKyHvceRca6Ijqxv2Jwy2b8+lWrcGWUBxDNBslkyhjYPdHBQLboRBlXX6ftEM1uki WMAR0dGuQMSbrep3GYdJaqNXn5RXgjsqOF3HMs4VYuyBnga+NLdjeXmpSU5pM7GVTaxHX84AMyjlo /RnABBDHNuQjwMnv04Yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwqfQ-0047W0-GR; Thu, 02 Jun 2022 19:39:36 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwqfN-0047VL-Nl for linux-arm-kernel@lists.infradead.org; Thu, 02 Jun 2022 19:39:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654198771; 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=P7DY6xYYaortLAkVD1OrkZ8mE7+5GrGuaQeLtKFchRk=; b=X/FaMVhk+BIXIKzhguEIm7cC9T4v6Ox8Q5jij3jZKWJIkfhiScQJHeg5KVuPbMhHy4qqL3 mJPNourxv0tC4n9oqZEe2qZ6R7O/GMS2rqRnR6BdagmPR1PyjXm9bz+6OePIX9jehQo3xJ nUPMvcNNGbcM7htNFWXtZtMPsrisD7g= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-deEBugm0On64kwYRllPbsA-1; Thu, 02 Jun 2022 15:39:30 -0400 X-MC-Unique: deEBugm0On64kwYRllPbsA-1 Received: by mail-wr1-f71.google.com with SMTP id t2-20020adfe442000000b002108370e7a3so870361wrm.3 for ; Thu, 02 Jun 2022 12:39:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=P7DY6xYYaortLAkVD1OrkZ8mE7+5GrGuaQeLtKFchRk=; b=UMoTAb+TusL297MJeRfPehwecARgurFnQ+5n4M6SGBimEEBCkNerZi39srWcUUEq+n ItBxBMuIYrA4hrJKCfuiVDuuMuGbdPL4yvH4y0LBT3IRkJqtBVoFkUt56gMfG2qeUbUq o5FtIdQKo1Z9D5MIJONPfKsjl3w+ay/8Ag4yQCGyEu4hoxedk9Y9r+/SCz0OgcSWLWbS WNI0KQUa0jrWh7BdLSih5Ia/jn0KyeE3xDNGtMM8V32xfFJ5Txbiwn5eO55MLA/6Hkzw oXCM8aA0cdkeoghgUkO/v4yiropI5drA3Kq92GT4z0lpMpOoXvcjthvWuOt32OuAiSL6 aL1w== X-Gm-Message-State: AOAM5324wAd83p+BVNzYR0aX63i27j1gAvwiWfj6WSiTsxITXbT21o2q U4ZHaSVSWLwgrPXt12ja/x1+cgGXhRYrRK8Zcv4jvmR5544yXzR7o3PkxrVkYBNU0tXSBhi1q3H FVf2Qfxra0z7Bn2tFRyoVjFGM+SokLuVFJeM= X-Received: by 2002:a1c:f710:0:b0:394:1960:e8a1 with SMTP id v16-20020a1cf710000000b003941960e8a1mr5369342wmh.154.1654198769407; Thu, 02 Jun 2022 12:39:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb5NUdRMKDEDqs3OehCuJ3A72dORJRZuj3TUcjk/IR3G+DoIyfVTVdoXGCVMUP1AOlTOWvvg== X-Received: by 2002:a1c:f710:0:b0:394:1960:e8a1 with SMTP id v16-20020a1cf710000000b003941960e8a1mr5369332wmh.154.1654198769164; Thu, 02 Jun 2022 12:39:29 -0700 (PDT) Received: from ?IPV6:2a01:e0a:59e:9d80:527b:9dff:feef:3874? ([2a01:e0a:59e:9d80:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id h9-20020a5d4309000000b002102af52a2csm6442171wrq.9.2022.06.02.12.39.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jun 2022 12:39:28 -0700 (PDT) Message-ID: Date: Thu, 2 Jun 2022 21:39:26 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 3/3] KVM: arm64: Warn if accessing timer pending state outside of vcpu context To: Marc Zyngier , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: Ricardo Koller , James Morse , Suzuki K Poulose , Alexandru Elisei , Oliver Upton , kernel-team@android.com References: <20220602083025.1110433-1-maz@kernel.org> <20220602083025.1110433-4-maz@kernel.org> From: Eric Auger In-Reply-To: <20220602083025.1110433-4-maz@kernel.org> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eauger@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220602_123933_921595_982DE594 X-CRM114-Status: GOOD ( 18.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Marc, On 6/2/22 10:30, Marc Zyngier wrote: > A recurrent bug in the KVM/arm64 code base consists in trying to > access the timer pending state outside of the vcpu context, which > makes zero sense (the pending state only exists when the vcpu > is loaded). > > In order to avoid more embarassing crashes and catch the offenders > red-handed, add a warning to kvm_arch_timer_get_input_level() and > return the state as non-pending. This avoids taking the system down, > and still helps tracking down silly bugs. > > Signed-off-by: Marc Zyngier Reviewed-by: Eric Auger Eric > --- > arch/arm64/kvm/arch_timer.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c > index 5290ca5db663..bb24a76b4224 100644 > --- a/arch/arm64/kvm/arch_timer.c > +++ b/arch/arm64/kvm/arch_timer.c > @@ -1230,6 +1230,9 @@ bool kvm_arch_timer_get_input_level(int vintid) > struct kvm_vcpu *vcpu = kvm_get_running_vcpu(); > struct arch_timer_context *timer; > > + if (WARN(!vcpu, "No vcpu context!\n")) > + return false; > + > if (vintid == vcpu_vtimer(vcpu)->irq.irq) > timer = vcpu_vtimer(vcpu); > else if (vintid == vcpu_ptimer(vcpu)->irq.irq) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel