From patchwork Fri Jan 27 11:39:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 49287 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp787645wrn; Fri, 27 Jan 2023 03:45:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXv5t6ReUIOCaIlY7M8NRKPtm3F8iGriSLCB2hV2DKoNhzm2B27k916SsV/lESz/53xcFUYw X-Received: by 2002:a05:6a20:c6c9:b0:b8:8a19:d6ad with SMTP id gw9-20020a056a20c6c900b000b88a19d6admr37534427pzb.24.1674819902581; Fri, 27 Jan 2023 03:45:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674819902; cv=none; d=google.com; s=arc-20160816; b=bNpMXSserEF8S4Vf1u+3uP7Lk93OnX7+z5BFfHevZvuvN8bFrUmXHkZMRycS44X7cu lxUEEx3Teaau6vuhTzrRvyVLXJhIqkXqNvZoDfaRNvdAyuLqB7WLlAwyBijXtcM8CfVW /gZttlCErK7/s/djDPKjqXc6GMAkhYA8ptbI+VYgTA43H1vclEx9IiZGKad90+XUfTST M1S9J0wXv8Qvq2wJiZL9DE0/sh5HHvOrMJIPCc1FdGcO0z4a/9TWZM9RXLdFkOwK90JI HpDTPEAwLZNkxrlnovTB1GspJR5Bl7OdM2KCYbctzhUkkbjoJBBCeUlrOE//+FdXYiQ2 hNDw== 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; bh=45tJhW8LK9kOcuv5g0pkTmwLQYYbK8Y9dFRZ1ypH7SI=; b=ghAQwihbyaA+dBddBkQ4S6r20POADnLdXhCqnrugBjMv6EEB30+qO9RyXJF3/Q7h/C QspUNM/61EUIP338/aKXgaO982zC8ELlT6dtfBN4urgPT2THIGYYXUM7My101BeSKD6L KFlGfcA/HEfEmJf+FMDiGwTUg587O126DpIfG2Getzpecck+da4ZdxJ7SqgKEye+2CoR xz4miHjQwrJRDqkJ6+0VRygqVC7ikAHaE9BKQ3zCkZ0agglur0c/bxM65WctaT1Z3x4K p8F4LPZFMiG3JtTh34Tp12oW7nauIxw96SSaqedodeimQo0kI4pFHYRq9av7T5HDa9Mp zDZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a639d04000000b004a26c35feeesi4089572pgd.859.2023.01.27.03.44.49; Fri, 27 Jan 2023 03:45:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233838AbjA0Lky (ORCPT + 99 others); Fri, 27 Jan 2023 06:40:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234195AbjA0Lki (ORCPT ); Fri, 27 Jan 2023 06:40:38 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 80CC710F4; Fri, 27 Jan 2023 03:40:20 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68AA515DB; Fri, 27 Jan 2023 03:40:39 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D6A303F64C; Fri, 27 Jan 2023 03:39:54 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 03/31] hw: cfi flash: Handle errors in memory transitions Date: Fri, 27 Jan 2023 11:39:04 +0000 Message-Id: <20230127113932.166089-4-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756175954460918007?= X-GMAIL-MSGID: =?utf-8?q?1756175954460918007?= Handle failures in creating the memory maps and back in transitioning the CFI flash. e.g., with MTE enabled, CFI flash emulation breaks with the map operation, silently. And we later hit unhandled aborts in the guest. To avoid such issues, let us make sure we catch the error and handle it right at source. Signed-off-by: Suzuki K Poulose --- hw/cfi_flash.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/cfi_flash.c b/hw/cfi_flash.c index 7faecdfb..bce546bc 100644 --- a/hw/cfi_flash.c +++ b/hw/cfi_flash.c @@ -455,6 +455,8 @@ static int map_flash_memory(struct kvm *kvm, struct cfi_flash_device *sfdev) KVM_MEM_TYPE_RAM | KVM_MEM_TYPE_READONLY); if (!ret) sfdev->is_mapped = true; + else + die("CFI Flash: ERROR: Unable to map memory: %d\n", ret); return ret; } @@ -472,6 +474,8 @@ static int unmap_flash_memory(struct kvm *kvm, struct cfi_flash_device *sfdev) if (!ret) sfdev->is_mapped = false; + else + die("CFI Flash: Failed to unmap Flash %d", ret); return ret; }