As pointed by Lorenzo, when a cpu powers down, the L1 cache must be flushed
before, otherwise:
* data cachelines are not empty and the other cpu may fetch data
* cpu will lost some data leading to a memory corruption
Note this bug is very difficult to reproduce and this test will not spot the
issue everytime.
Signed-off-by: Daniel Lezcano <daniel.lezcano(a)linaro.org>
---
cpuidle/cpuidle-l1.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
cpuidle/cpuidle_05.sh | 42 ++++++++++++++++++++++++++++
cpuidle/cpuidle_05.txt | 1 +
3 files changed, 115 insertions(+)
create mode 100644 cpuidle/cpuidle-l1.c
create mode 100755 cpuidle/cpuidle_05.sh
create mode 100644 cpuidle/cpuidle_05.txt
diff --git a/cpuidle/cpuidle-l1.c b/cpuidle/cpuidle-l1.c
new file mode 100644
index 0000000..bbcde28
--- /dev/null
+++ b/cpuidle/cpuidle-l1.c
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <pthread.h>
+#define BUFSIZE (4*1024)
+#define DEADBEEF 0xDEADBEEF
+static int buffer[BUFSIZE];
+
+static pthread_t threads[64];
+
+void *thread_routine(void *arg)
+{
+ int i, display = *(int *)arg;
+ int dummy;
+
+ for (i = 0; i < 100; i++) {
+
+ int j;
+
+ for (j = 0; j < BUFSIZE * 1000; j++) {
+ dummy = buffer[j % BUFSIZE];
+ dummy++;
+ }
+
+ usleep(200000);
+
+ if (buffer[i] != DEADBEEF) {
+ fprintf(stderr, "memory corruption\n");
+ return (void *)-1;
+ }
+
+ if (display == 0)
+ printf("%d%%%s", i, i < 10 ? "\b\b" : "\b\b\b");
+ }
+
+ if (display == 0)
+ printf(" \b\b\b\b");
+
+ return NULL;
+}
+
+int main(int argc, char *argv[])
+{
+ int i, ret = 0;
+ int nrcpus = sysconf(_SC_NPROCESSORS_ONLN);
+
+ for (i = 0; i < BUFSIZE; i++)
+ buffer[i] = DEADBEEF;
+
+ setbuf(stdout, NULL);
+
+ for(i = 0; i < nrcpus; i++) {
+
+ if (pthread_create(&threads[i], NULL, thread_routine, &i)) {
+ perror("pthread_create");
+ return 1;
+ }
+
+ }
+
+ for (i = 0; i < nrcpus; i++) {
+ void *result;
+ pthread_join(threads[i], &result);
+
+ if (result == (void *)-1)
+ ret = 1;
+ }
+
+ return ret;
+}
diff --git a/cpuidle/cpuidle_05.sh b/cpuidle/cpuidle_05.sh
new file mode 100755
index 0000000..679439d
--- /dev/null
+++ b/cpuidle/cpuidle_05.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# PM-QA validation test suite for the power management on Linux
+#
+# Copyright (C) 2011, Linaro Limited.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributors:
+# Daniel Lezcano <daniel.lezcano(a)linaro.org> (IBM Corporation)
+# - initial API and implementation
+#
+
+# URL : https://wiki.linaro.org/WorkingGroups/PowerManagement/Resources/TestSuite/P…
+
+source ../include/functions.sh
+
+CPUIDLE_L1=./cpuidle-l1
+
+if [ $(id -u) -ne 0 ]; then
+ log_skip "run as non-root"
+ exit 0
+fi
+
+check_cpuidle_l1() {
+ check "Fill L1 cache and sleep" "./$CPUIDLE_L1"
+}
+
+check_cpuidle_l1
+test_status_show
diff --git a/cpuidle/cpuidle_05.txt b/cpuidle/cpuidle_05.txt
new file mode 100644
index 0000000..1f80e36
--- /dev/null
+++ b/cpuidle/cpuidle_05.txt
@@ -0,0 +1 @@
+Run cpuidle L1 test program to catch L1 flush missing vs cpu power down
--
1.7.9.5
Hi all,
I used the image:
arndale-saucy_server_20140222-611.img
I boots well but when I unplug CPU1, the kernel crashes.
It seems related to the AFTR state (an idle state of cpuidle) and the
u-boot version which is 2013-rc1. It seems this issue does not happen
with a more recent u-boot (I was not yet able to test it).
I don't know where to fill the bug for this release.
Chander, any pointer to the right u-boot version you are using
successfully ?
Thanks
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
hi,
first of all, this isn't meant to be a distro trolling discussion, there
are better places for that ;-)
several days ago google HO started to fail after updating my debian/sid
setup. as discussed on G+ [1] and on googlegroups [2], that seemed to be
impacting anyone on debian/sid. when i realized that it was working on
debian/testing (Jessie) i decided just use 'testing'... however since last
evening update on 'testing', it started to fail too.. leaving me without
any working HO at all, which is quite inconvenient at Linaro..
after bisecting my system using snapshot.debian.org, i figured out which
package was the culprit:
# apt-cache policy libcairo2
libcairo2:
Installed: 1.12.14-4
Candidate: 1.12.14-4
Package pin: 1.12.14-4
Version table:
1.12.16-2 1001
500 http://ftp.fr.debian.org/debian/ testing/main amd64 Packages
*** 1.12.14-4 1001
500 http://snapshot.debian.org/archive/debian/20130927T214600Z/testing/main
amd64 Packages
100 /var/lib/dpkg/status
Simply downgrading libcairo2 [3] 'fixes' the problem. I know it's not
'fixing' it really, but i hope that this will be enough information so that
the real fix is uploaded.
In the mean time, if any of use use Debian , you can use that as a
workaround..
cheers
nico
[1] https://plus.google.com/u/0/108790110407014289037/posts/5q22d1ReavG
[2] https://productforums.google.com/d/msg/hangouts/vYsaeEnXJXs/hOy2HaW5LKoJ
[3]
http://snapshot.debian.org/archive/debian/20130927T214600Z/pool/main/c/cair…
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm pleased to announced that the first version of UEFI for QEMU/KVM
has bee released, and is available for public consumption. There's
still a fair number of bugs in this release, but feel free to grab it,
play with it, or try and break it
The (sparse) documentation is available here
https://wiki.linaro.org/LEG/UEFIforQEMU
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJTQvQmAAoJEGKVRgSEnX1QrgYH/iNJAwyPX3noTuqo/695yhs/
DlHVxfjMi3Woec0laIm8dPXUxWpI8ObQnAXqVoj3sLcu8x8lZyyH/qXWdS2XiVYa
NxNP7B4z8sQ2oKTBw9AH/lgNrfjq9kJwrFQdZnGnU5bBFiF52c4huVqv6kH0Uzsu
k3QpYWqLVJ+0WQvH9t/TjdEI2xaLw1r9vAbp3IIv8nydHRNUOaujSO2qYNQDqpu6
ydxp8FqF++jyW7Yy2MbcAk+s32ODxhMHQUHQ1CcucrxI0ezOBmBfD1zOgaOtTgEA
nlRAwId8rK5NpduLVs4LqUI9I0a4Oe9kvNv4WNyj/9N1LsGdsqKuh0pPb2rLstI=
=sI5b
-----END PGP SIGNATURE-----
Hello all,
Just so you know, both ARM Trusted Firmware (TF) and UEFI have changed.
The 13.03 release has TF code that is pre v0.3. Since v0.3, TF expects to
load all other bootloader stages from a "Firmware Image Package" (aka FIP).
This includes UEFI.
Also, the upstream UEFI code for FVP has changed. It is no longer built to
run from NOR flash at address zero, but instead, it runs from RAM.
This means that you cannot use the lastest TF with an old UEFI binary and
you cannot use the latest UEFI binary with the old TF.
I've updated the CI job for FVP's TF so that it now builds UEFI, then
builds TF, then build the FIP blob with the UEFI binary inside it.
Currently the job builds from the release-prep branch of linaro-edk2.git.
This actually contains the upstream Tianocore code at the moment, so it
will be missing a lot of the features you might want, like ethernet, or
Linaro's local-FDT mods.
I'll run another job after release-prep has been updated. And I'll have to
update the hwpack to include fip.bin and so on.
You can find the CI job here:
https://ci.linaro.org/jenkins/view/components/job/fvp-pre-boot/
With the output binaries here:
http://snapshots.linaro.org/components/kernel/fvp-pre-boot/38
And you can find the script here:
http://git.linaro.org/ci/fvp-pre-boot.git
The basic commands to build it all distil down to something like:
git clone git://git.linaro.org/uefi/linaro-edk2.git
cd linaro-edk2
uefi-build.sh fvp_minimal
export BL33=`pwd`/`find . -name FVP_AARCH64_EFI.fd`
cd ..
git clone git://git.linaro.org/arm/models/arm-trusted-firmware.git
cd arm-trusted-firmware
CROSS_COMPILE=aarch64-linux-gnu- make PLAT=${platform} all fip
Then you will have bl1.bin and fip.bin in build/fvp/release/.
When you launch the FVP model, you specify the bl1.bin as normal. However,
instead of passing the UEFI binary to the NOR Flash arg, you pass fip.bin,
eg:
-C bp.flashloader0.fname=<path to>/fip.bin
Hope that all helps.
Cheers,
Ryan.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
As I've made a fair bit of headway since LinaroConnect, I wanted to
drop a line on my current progress with porting TianoCore to KVM
Summary (tl;dr version):
KVM can start TianoCore, and boot all the way to shell, and access
HDDs via VirtioBlk. We can start grub and successfully retrieve files
from ext partitions, load a device tree, and start the kernel. The
kernel runs through most of the EFI stub, but falls over during
ExitBootServices()
Long Version:
So, after much blood sweat and tears, we're finally at the point of
trying to actually start a kernel, though this (for the moment)
remains an elusive goal. The current problem is that once we call
EBS(), we get an exception from EFI with no Image information, which
means the exception handler doesn't know where it came from. After
several seconds, we get a second exception from within DxeCore, and
then EFI falls over.
Debugging EFI is difficult and error prone, combined with limited
debug facilities from the gdb-stub in QEMU (no breakpoints), and no
decent way to load all of EFI itself (you have to run add-symbol-file
manually with the output of commands printed on the console;
supposedly its possible to generate a giant GdbSyms.dll file to import
in a single go, but I haven't succeeded at this). This is further
complicated that it appears we're asserting somewhere in a driver, and
short of adding printfs to *every* driver, its impossible to know
which is asseting.
Previous attempts to debug assets shows that EFI does "odd" things to
the stack when we hit an exception, making walking it with GDB
impossible. I need to figure out what madness EFI does with my SP so I
can get the entire stack on an explosion, but this remains at best
hopeful thinking.
Further complicating things is that during EBS, my print debugging
goes away. I might just cheat and roll a simple assembly function to
bang out messages through serial without calling anything else. Ugly
as sin, but this should let me get useful debug output through the EBS
framework. Complicating matters is that I need to locate each and all
EBS() event functions, which are spread *everywhere* in TianoCore, and
then debug them each individually.
I'm open to ideas on how best to accomplish this.
On a larger scale, there are a couple of other bugs and odds and ends
which currently affect us:
* wfi doesn't work
THis is probably the biggest w.r.t. to functionality that should work,
but doesn't. The EFI event loop is built on checking the timer, then
calling wfi to check the timer later. The problem here is we call wfi
... and UEFI never comes back despite events firing (I can put print
code in the interrupt handler to confirm this). This may be related to
the VGIC errors I get running kvm under foundation, but haven't taken
the time to properly nail down the bug here.
This was worked around by commenting out the wfi, turning event loop
into a busy loop, but this has to be resolved before we can ever
consider merging it
* No RTC
I looked through virt.c in KVM, and as best I can tell, I've got no
RTC at all (no PL031). It also appears that the kernel can't get RTC
as running a kernel gets me a 1970 clock. I'm not sure if this is by
design or not, but it causes GetTime() to return EFI_ERROR, and I
suspect may be one of the exceptions I'm getting avoid (Shell prints a
ton of warnings that GetTime is busted).
* No terminfo support (not ARM specific)
EFI assumes its working against a real console or terminal. As such,
it doesn't respect anything like termcap or such, and output gets
jumbled due to incorrect escape sequencies and such. This isn't
specific to ARM as I get identical behavior with OVMF running on stdio
or over telnet. Backspace for instance requires me to type ^H into the
console manually
As we expect to have this usable remotely, we need to determine how to
handle the terminal and escape sequences properly so we're not
printing garbage to the screen. A "dumb" mode might just be the best
way to handle this, but something like grub do display fancy graphics.
Ideas welcome.
If anyone wants to play with it, my code is on git, but requires a bit
of setup to get running, and you need a patch to KVM to successfully
start UEFI at the moment.
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJTNTJTAAoJEGKVRgSEnX1Qm2YH/jzWQjB/DPSHdv33hUlxVuIm
j2AGElid7HM+3gp5U/ILdXvCyP9LFg8RATsvUa7bSHdwFZxRdAqYUWzm/Jxg6ZYV
kyTzTDuPhbXp8koVLF14H/oGlpwnEH5rhzNa3UeRZTNYnNp3UMeZ1NXgGu9ziCfk
hMGGteTMfV/6fGD6AETtlpD99KKwFiprD198QAil2rpVRi4WZBcgp7Y9/c/+cLfy
sJD7p+zN8jBh9r9njpxh0o5rrQoG3N1NAemPGbSAc+qMMYCDOmjasGLwYiJuuMDy
apRBM9+pbYsEgBGxM1z3XGywBJWBaLGzizk8vfPN2kN70/F7RW89X1rqG/95Ais=
=OwC0
-----END PGP SIGNATURE-----