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 2A9FCECE591 for ; Tue, 10 Sep 2024 00:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=NMaP86bC+hPhOjPzwPjEKilwC9SBm5gKL8ioVFK2IxE=; b=jvyEPg82fn9cry7tCB/sE+kb7m Pv/C/q/ZjW33pHoIdCiOjRrhbrlS+npGKi35pTQJPr+Wy/E8UOnDVVpzinTRzaOFTk+oqaXV2Ne5K j0IWv13midiPjby2dgy2zkruPyNQ/m/csz+tyaC+2qz8IEzwbXRZQc+Z0kLWGowYsaVxihO9VCxxU iLTZ8bvrmjbhqWKTvqQgePWAmGsM7Fo9u9XAkZedraK7lP4yFWSnL0CRZKOfb22XoPj6SqIstYrgb hNT7lX/Faiw9gtegtcRzIvO4CIH4DhFF5qYlWA9k5fFBOqhojcgHe2qPrrqBBzppNR5wHzC0ZBPCK 7QbU4ewg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snoT9-00000003ezT-43hi; Tue, 10 Sep 2024 00:10:55 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snoS7-00000003eqS-41Zd for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 00:09:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725926991; 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=NMaP86bC+hPhOjPzwPjEKilwC9SBm5gKL8ioVFK2IxE=; b=b6qyQFOgnv1t4X1UngXsgxFeYmoxva3+LyY1zbO473HJfx9Zz6qFwBBHeVQok+Lfi5BZLD GuPPuhRNQf7rDD2MulUTQLJYDQqsCgK/IUvuLAs1xXs8KivqHo/A7YzeSwSK02oly8RnjJ McpBGb0mBShxr6gBWDdzZvaHTrkmhf8= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-0uytecfPNWedTmhqYOQkhw-1; Mon, 09 Sep 2024 20:09:49 -0400 X-MC-Unique: 0uytecfPNWedTmhqYOQkhw-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-718e2757e5dso3258273b3a.0 for ; Mon, 09 Sep 2024 17:09:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725926988; x=1726531788; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NMaP86bC+hPhOjPzwPjEKilwC9SBm5gKL8ioVFK2IxE=; b=gZdyw3dSbO6biSwbIksUiqU0tbwSGtnEXtdq8dfWRMGdFoik3REWgsKwtLtYdQqDwa STqIoKOuhXsFqlEgJAZX8/Hd4LgznSZZXa77ZP9JDKFOj0yXfHUIa0dPwYsRNizphvCt IIgLcD1QhmWpGnfPB+vXRGHroxpioODdPJgXke3zdwyVucrFy7qjXOuB/waB+2LAabXa 6tczJcX0HTsv9N7ouuf/zSwXIcX02/hxIm/zpAILUEey62q9Gc9PDbCosWDPXZvDacq7 U4QCI2uBLaWPi0fLB+k4RaV2ntzoOHP1ypG9aHTVzKIarspVBwYfkLHicAJf+rQgAX6r OEUg== X-Forwarded-Encrypted: i=1; AJvYcCWevWGUjRTSRpQptAUCMTWu0UshJjc4Yy3t+XfkS7vxdcKPs4XaPGDOCTYghS/gZmQSRv/0SQhFIXlSUs/QlG/8@lists.infradead.org X-Gm-Message-State: AOJu0YzOtxib6wNzseMuQINo3vr/oU09L56MgLu8JFQ45n/5fleMl0K2 /x+nrTctiMM2Mkj+vUnV6maHHQSMnQVzCQAjvP00CIx2eTB/cNnSVxr6Kt/MuxQ+/0tMtgm2UTY L02T32MlSyhfLH0sWHqh/Q7m0Nm8xAtGX9lQ9DACcFyHhom0UUm5WaFg95hyqLg9vppa9xXs0 X-Received: by 2002:a05:6a00:2ea8:b0:717:9896:fb03 with SMTP id d2e1a72fcca58-71907eb88a7mr1676590b3a.6.1725926988284; Mon, 09 Sep 2024 17:09:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOPTJ+MAzzAaW9hu5Sm5LtqVY+qPsIcrMrv6ipiDOnyMneCo1T4P1xJfwBR5Lh/LAWTBHDRg== X-Received: by 2002:a05:6a00:2ea8:b0:717:9896:fb03 with SMTP id d2e1a72fcca58-71907eb88a7mr1676558b3a.6.1725926987824; Mon, 09 Sep 2024 17:09:47 -0700 (PDT) Received: from [192.168.68.54] ([103.210.27.31]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fe29f6sm283845b3a.67.2024.09.09.17.09.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Sep 2024 17:09:47 -0700 (PDT) Message-ID: Date: Tue, 10 Sep 2024 10:09:38 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 05/19] arm64: Detect if in a realm and set RIPAS RAM To: Steven Price , Catalin Marinas Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Shanker Donthineni , Alper Gun References: <20240819131924.372366-1-steven.price@arm.com> <20240819131924.372366-6-steven.price@arm.com> <2e8caa91-bf66-4555-87b3-52f469b2c7ef@arm.com> From: Gavin Shan In-Reply-To: <2e8caa91-bf66-4555-87b3-52f469b2c7ef@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240909_170952_501120_4A0BBAF4 X-CRM114-Status: GOOD ( 15.48 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 8/31/24 1:54 AM, Steven Price wrote: > On 26/08/2024 11:03, Catalin Marinas wrote: >> On Mon, Aug 19, 2024 at 02:19:10PM +0100, Steven Price wrote: [...] >>> + >>> +void __init arm64_rsi_setup_memory(void) >>> +{ >>> + u64 i; >>> + phys_addr_t start, end; >>> + >>> + if (!is_realm_world()) >>> + return; >>> + >>> + /* >>> + * Iterate over the available memory ranges and convert the state to >>> + * protected memory. We should take extra care to ensure that we DO NOT >>> + * permit any "DESTROYED" pages to be converted to "RAM". >>> + * >>> + * BUG_ON is used because if the attempt to switch the memory to >>> + * protected has failed here, then future accesses to the memory are >>> + * simply going to be reflected as a SEA (Synchronous External Abort) >>> + * which we can't handle. Bailing out early prevents the guest limping >>> + * on and dying later. >>> + */ >>> + for_each_mem_range(i, &start, &end) { >>> + BUG_ON(rsi_set_memory_range_protected_safe(start, end)); >>> + } >> >> Would it help debugging if we print the memory ranges as well rather >> than just a BUG_ON()? >> > > Yes that would probably be useful - I'll fix that. > One potential issue I'm seeing is WARN_ON() followed by BUG_ON(). They're a bit duplicate. I would suggest to remove the WARN_ON() and print informative messages in rsi_set_memory_range(). setup_arch arm64_rsi_setup_memory // BUG_ON(error) rsi_set_memory_range_protected_safe rsi_set_memory_range // WARN_ON(error) Thanks, Gavin