From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4B5252115F523 for ; Tue, 5 Jun 2018 04:29:54 -0700 (PDT) Received: by mail-wr0-x241.google.com with SMTP id l41-v6so2019748wre.7 for ; Tue, 05 Jun 2018 04:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ytDSL1YG9HKvzNcZiyr+hohBVjDlTlC4KFMsHpd5c54=; b=PrylvspWJe2E8DsuBZ01gzO9reeLN71Lo1+28Et7J1A5JnvAC1/3TXtgmqixTHoT32 QwBgM3Cs6s3fTSk6MSmzJMbtbXHeujv1oobSNMXKzLd4u0+LRK4DvA3DrxtDfw2rbcJw I8lzhcUI1XULrt12DSiWvnG+eGtg/+HyPQFCw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ytDSL1YG9HKvzNcZiyr+hohBVjDlTlC4KFMsHpd5c54=; b=KJTa6+DlvYcKpffDSvavZnd3WtixMgEAZ/qgyf3JlXkRS17iNvAw+6bk8m3mGzhmRb LEhZQIW7yzQauVkvp+8FRR4yFEb+xZ0xAu7sBnP5dcq4GThI7PDt30DUGeizTGz+vO5k 9fCPpX3MgjqLuHBYEus1k5HlTgWSVzg8tjh51s2m9gWn5++UWTkl0fU7Kb+Oto7tRg9n abVvUlgHBYr01VerassarOg6wELKYixq93lTJKVoHACs1diYSwdgoxyUaaoz9pmvpHjF QBh1xSQIg73H60DRaiWI40nbmT3vJHOmFKtwpzHsFQ9sl05205R/uWFQFCLyAwObJhi4 nfJw== X-Gm-Message-State: ALKqPwfQn00ygg9UuhT8dBN+wcp4wBayw5Wmdiz7e+TFUGwM3DCxnP/W SDDZQopnVuIzgeMnJVxcpBBVKFyB3iM= X-Google-Smtp-Source: ADUXVKJgmYKmQw/TOuPyHWQoMLX8VANr6LLZjQOBEgxJ0Gy2y3R5TJ+9R5BeuQguA9t5fcves9YG4g== X-Received: by 2002:adf:9924:: with SMTP id x33-v6mr20491564wrb.29.1528198193583; Tue, 05 Jun 2018 04:29:53 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id x65-v6sm1689838wme.31.2018.06.05.04.29.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 04:29:52 -0700 (PDT) Date: Tue, 5 Jun 2018 12:29:50 +0100 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, lersek@redhat.com Message-ID: <20180605112950.ta2jgg5ufy4zjeuj@bivouac.eciton.net> References: <20180605110543.17663-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20180605110543.17663-1-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH] ArmVirtPkg: implement KVM safe IoLib instance X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jun 2018 11:29:55 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jun 05, 2018 at 01:05:43PM +0200, Ard Biesheuvel wrote: > KVM on ARM refuses to decode load/store instructions used to perform > I/O to emulated devices, and instead relies on the exception syndrome > information to describe the operand register, access size, etc. > This is only possible for instructions that have a single input/output > register (as opposed to ones that increment the offset register, or > load/store pair instructions, etc). Otherwise, QEMU crashes with the > following error > > error: kvm run failed Function not implemented > R00=01010101 R01=00000008 R02=00000048 R03=08000820 > R04=00000120 R05=7faaa0e0 R06=7faaa0dc R07=7faaa0e8 > R08=7faaa0ec R09=7faaa088 R10=000000ff R11=00000080 > R12=ff000000 R13=7fccfe08 R14=7faa835f R15=7faa887c > PSR=800001f3 N--- T svc32 > QEMU: Terminated > > and KVM produces a warning such as the following in the kernel log > > kvm [17646]: load/store instruction decoding not implemented > > The IoLib implementation provided by MdePkg/Library/BaseIoLibIntrinsic > is based on C code, and when LTO is in effect, the MMIO accesses could > be merged with, e.g., manipulations of the loop counter, producing > opcodes that KVM does not support for emulated MMIO. > > So instead, let's reimplement IoLib in a KVM safe manner. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > Yet another approach for the KVM MMIO emulation issue. Note that this one > (as well as the MdePkg) affect both AArch64 and ARM. This is deliberate, > given that there is no reason AArch64 should be immune to this: we simply > haven't triggered the issue yet. I'm happier with this version (at the same time as I'm sad we're splitting this out). Reviewed-by: Leif Lindholm > ArmVirtPkg/Library/ArmVirtIoLib/AArch64/ArmVirtMmio.S | 164 ++ > ArmVirtPkg/Library/ArmVirtIoLib/Arm/ArmVirtMmio.S | 154 ++ > ArmVirtPkg/Library/ArmVirtIoLib/Arm/ArmVirtMmio.asm | 165 ++ > ArmVirtPkg/Library/ArmVirtIoLib/ArmVirtIoLib.c | 589 +++++ > ArmVirtPkg/Library/ArmVirtIoLib/ArmVirtIoLib.h | 188 ++ > ArmVirtPkg/Library/ArmVirtIoLib/ArmVirtIoLib.inf | 49 + > ArmVirtPkg/Library/ArmVirtIoLib/IoHighLevel.c | 2358 ++++++++++++++++++++ > ArmVirtPkg/Library/ArmVirtIoLib/IoLibMmioBuffer.c | 413 ++++ > 8 files changed, 4080 insertions(+)