1 #include <nuklear.h>
2 
3 #include <ui/display.h>
4 #include <ui/font.h>
5 #include <ui/window.h>
6 
7 #include <vuln/meltdown.h>
8 
9 #include "style.h"
10 
11 void
show_meltdown_tab(struct nk_context * ctx,struct style * style,struct meltdown_info * info,int flags)12 show_meltdown_tab(struct nk_context *ctx, struct style *style, struct meltdown_info *info, int flags)
13 {
14 	float ratios[] = {0.3f, 0.7f};
15 	int ret;
16 
17 	ui_set_font(ctx, style->header_font);
18 	ret = nk_tree_push(ctx, NK_TREE_TAB, "Meltdown", flags);
19 	ui_set_font(ctx, style->font);
20 
21 	if (!ret)
22 		return;
23 
24 	nk_layout_row(ctx, NK_DYNAMIC, 20, 2, ratios);
25 	ui_set_font(ctx, style->bold_font);
26 	nk_label_wrap(ctx, "Status:");
27 	ui_set_font(ctx, style->font);
28 
29 	if (info->affected) {
30 		nk_label_colored_wrap(ctx, "Vulnerable", style->red);
31 	} else {
32 		nk_label_colored_wrap(ctx, "Not Affected", style->green);
33 	}
34 
35 	ui_set_font(ctx, style->bold_font);
36 	nk_label_wrap(ctx, "KPTI Present:");
37 	ui_set_font(ctx, style->font);
38 
39 	if (info->kpti_present) {
40 		nk_label_colored_wrap(ctx, "Yes", style->green);
41 	} else {
42 		nk_label_colored_wrap(ctx, "No", info->affected ? style->red : style->black);
43 	}
44 
45 	ui_set_font(ctx, style->bold_font);
46 	nk_label_wrap(ctx, "KPTI Enabled:");
47 	ui_set_font(ctx, style->font);
48 
49 	if (info->kpti_enabled) {
50 		nk_label_colored_wrap(ctx, "Yes", style->green);
51 	} else {
52 		nk_label_colored_wrap(ctx, "No", info->affected ? style->red : style->black);
53 	}
54 
55 	ui_set_font(ctx, style->bold_font);
56 	nk_label_wrap(ctx, "PCID Accelerated:");
57 	ui_set_font(ctx, style->font);
58 
59 	if (info->has_pcid) {
60 		nk_label_wrap(ctx, "Yes");
61 	} else {
62 		nk_label_wrap(ctx, "No");
63 	}
64 
65 	ui_set_font(ctx, style->bold_font);
66 	nk_label_wrap(ctx, "PCID Invalidation:");
67 	ui_set_font(ctx, style->font);
68 
69 	if (info->has_invpcid) {
70 		nk_label_wrap(ctx, "Yes");
71 	} else {
72 		nk_label_wrap(ctx, "No");
73 	}
74 
75 	nk_tree_pop(ctx);
76 }
77