From 813ec29d3c7de28398b2a917b63197a77783eaac Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Wed, 20 Nov 2019 13:15:56 -0500 Subject: [PATCH] exec.c: add a check between constants to see whether we could skip The maximum level is defined as P_L2_LEVELS and skip is defined with 6 bits, which means if P_L2_LEVELS < (1 << 6), skip never exceeds the boundary. Since this check is between two constants, which leverages compiler to optimize the code based on different configuration. Backports commit 526ca2360ea1cd947f74c8c6c38b91b9d6fcfdb5 from qemu --- qemu/exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qemu/exec.c b/qemu/exec.c index e7c9ce5c..49497b59 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -247,7 +247,8 @@ static void phys_page_compact(PhysPageEntry *lp, Node *nodes, unsigned long *com assert(valid_ptr < P_L2_SIZE); /* Don't compress if it won't fit in the # of bits we have. */ - if (lp->skip + p[valid_ptr].skip >= (1 << 6)) { + if (P_L2_LEVELS >= (1 << 6) && + lp->skip + p[valid_ptr].skip >= (1 << 6)) { return; }