Skip to content

Commit 98eb1bc

Browse files
authored
Merge pull request #1258 from fwsGonzo/dev
Work-around for ghost in the machine, remove another work-around
2 parents 603a944 + 3ab64de commit 98eb1bc

5 files changed

Lines changed: 39 additions & 38 deletions

File tree

api/net/tls/server.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class Server : public Botan::TLS::Callbacks, public tcp::Stream
3737

3838
Server(Connection_ptr remote,
3939
Botan::RandomNumberGenerator& rng,
40-
Botan::Credentials_Manager& credman)
40+
Botan::Credentials_Manager& credman)
4141
: tcp::Stream({remote}),
4242
m_creds(credman),
43-
m_session_manager(rng),
43+
m_session_manager(),
4444
m_tls(*this, m_session_manager, m_creds, m_policy, rng)
4545
{
4646
assert(tcp->is_connected());
@@ -140,7 +140,7 @@ class Server : public Botan::TLS::Callbacks, public tcp::Stream
140140
{
141141
auto buffff = std::shared_ptr<uint8_t> (new uint8_t[buf_len]);
142142
memcpy(buffff.get(), buf, buf_len);
143-
143+
144144
o_read(buffff, buf_len);
145145
}
146146
}
@@ -157,7 +157,7 @@ class Server : public Botan::TLS::Callbacks, public tcp::Stream
157157

158158
Botan::Credentials_Manager& m_creds;
159159
Botan::TLS::Strict_Policy m_policy;
160-
Botan::TLS::Session_Manager_In_Memory m_session_manager;
160+
Botan::TLS::Session_Manager_Noop m_session_manager;
161161

162162
Botan::TLS::Server m_tls;
163163
};

src/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ set(OS_OBJECTS
7070
)
7171

7272
add_library(os STATIC ${OS_OBJECTS} apic_boot.o)
73-
74-
set_source_files_properties(os virtio/virtio.cpp PROPERTIES COMPILE_FLAGS "-mno-avx -msse3")
75-
7673
add_dependencies(os PrecompiledLibraries botan)
7774

7875
file(GLOB CXX_ABI crt/cxxabi/*.cpp)

src/drivers/virtionet.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,16 @@ VirtioNet::VirtioNet(hw::PCI_Device& d)
169169
}
170170
#endif
171171

172+
CHECK(this->link_up(), "Link up");
172173
// Done
173-
INFO("VirtioNet", "Driver initialization complete");
174-
CHECK(_conf.status & 1, "Link up\n");
175-
rx_q.kick();
174+
if (this->link_up()) {
175+
rx_q.kick();
176+
}
177+
}
178+
179+
bool VirtioNet::link_up() const noexcept
180+
{
181+
return _conf.status & 1;
176182
}
177183

178184
void VirtioNet::msix_conf_handler()
@@ -259,9 +265,9 @@ VirtioNet::recv_packet(uint8_t* data, uint16_t size)
259265
#endif
260266

261267
new (ptr) net::Packet(
262-
sizeof(virtio_net_hdr),
263-
size - sizeof(virtio_net_hdr),
264-
sizeof(virtio_net_hdr) + packet_len(),
268+
sizeof(virtio_net_hdr),
269+
size - sizeof(virtio_net_hdr),
270+
sizeof(virtio_net_hdr) + packet_len(),
265271
&bufstore());
266272

267273
return net::Packet_ptr(ptr);
@@ -274,9 +280,9 @@ VirtioNet::create_packet(int link_offset)
274280
auto* ptr = (net::Packet*) buffer.addr;
275281

276282
new (ptr) net::Packet(
277-
sizeof(virtio_net_hdr) + link_offset,
278-
0,
279-
sizeof(virtio_net_hdr) + packet_len(),
283+
sizeof(virtio_net_hdr) + link_offset,
284+
0,
285+
sizeof(virtio_net_hdr) + packet_len(),
280286
buffer.bufstore);
281287

282288
return net::Packet_ptr(ptr);

src/drivers/virtionet.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ class VirtioNet : Virtio, public net::Link_layer<net::Ethernet> {
156156
return tx_q.num_free() / 2;
157157
}
158158

159+
bool link_up() const noexcept;
160+
159161
void deactivate() override;
160162

161163
void move_to_this_cpu() override;

src/virtio/virtio.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,18 @@ Virtio::Virtio(hw::PCI_Device& dev)
134134
}
135135

136136
INFO("Virtio", "Initialization complete");
137-
138-
// It would be nice if we new that all queues were the same size.
139-
// Then we could pass this size on to the device-specific constructor
140-
// But, it seems there aren't any guarantees in the standard.
141-
142-
// @note this is "the Legacy interface" according to Virtio std. 4.1.4.8.
143-
// uint32_t queue_size = hw::inpd(_iobase + 0x0C);
144137
}
145138

146-
void Virtio::get_config(void* buf, int len){
139+
void Virtio::get_config(void* buf, int len)
140+
{
147141
// io addr is different when MSI-X is enabled
148142
uint32_t ioaddr = _iobase;
149143
ioaddr += (has_msix()) ? VIRTIO_PCI_CONFIG_MSIX : VIRTIO_PCI_CONFIG;
150144

151145
uint8_t* ptr = (uint8_t*) buf;
152-
for (int i = 0; i < len; i++)
146+
for (int i = 0; i < len; i++) {
153147
ptr[i] = hw::inp(ioaddr + i);
148+
}
154149
}
155150

156151

@@ -162,7 +157,7 @@ uint8_t Virtio::get_legacy_irq()
162157
{
163158
// Get legacy IRQ from PCI
164159
uint32_t value = _pcidev.read_dword(PCI::CONFIG_INTR);
165-
if ((value & 0xFF) > 0 && (value & 0xFF) < 32){
160+
if ((value & 0xFF) != 0xFF) {
166161
return value & 0xFF;
167162
}
168163
return 0;
@@ -173,7 +168,6 @@ uint32_t Virtio::queue_size(uint16_t index) {
173168
return hw::inpw(iobase() + VIRTIO_PCI_QUEUE_SIZE);
174169
}
175170

176-
#define BTOP(x) ((unsigned long)(x) >> PAGESHIFT)
177171
bool Virtio::assign_queue(uint16_t index, const void* queue_desc)
178172
{
179173
hw::outpw(iobase() + VIRTIO_PCI_QUEUE_SEL, index);
@@ -196,20 +190,12 @@ uint32_t Virtio::probe_features() {
196190
}
197191

198192
void Virtio::negotiate_features(uint32_t features) {
199-
_features = hw::inpd(_iobase + VIRTIO_PCI_HOST_FEATURES);
200-
//_features &= features; //SanOS just adds features
201-
_features = features;
202-
debug("<Virtio> Wanted features: 0x%lx \n",_features);
193+
//_features = hw::inpd(_iobase + VIRTIO_PCI_HOST_FEATURES);
194+
this->_features = features;
195+
debug("<Virtio> Wanted features: 0x%lx \n", _features);
203196
hw::outpd(_iobase + VIRTIO_PCI_GUEST_FEATURES, _features);
204197
_features = probe_features();
205198
debug("<Virtio> Got features: 0x%lx \n",_features);
206-
207-
}
208-
209-
void Virtio::setup_complete(bool ok) {
210-
uint8_t status = ok ? VIRTIO_CONFIG_S_DRIVER_OK : VIRTIO_CONFIG_S_FAILED;
211-
debug("<VIRTIO> status: %i ",status);
212-
hw::outp(_iobase + VIRTIO_PCI_STATUS, hw::inp(_iobase + VIRTIO_PCI_STATUS) | status);
213199
}
214200

215201
void Virtio::move_to_this_cpu()
@@ -232,3 +218,13 @@ void Virtio::move_to_this_cpu()
232218
}
233219
}
234220
}
221+
222+
void Virtio::setup_complete(bool ok)
223+
{
224+
uint8_t value = hw::inp(_iobase + VIRTIO_PCI_STATUS);
225+
value |= ok ? VIRTIO_CONFIG_S_DRIVER_OK : VIRTIO_CONFIG_S_FAILED;
226+
if (!ok) {
227+
INFO("Virtio", "Setup failed, status: %hhx", value);
228+
}
229+
hw::outp(_iobase + VIRTIO_PCI_STATUS, value);
230+
}

0 commit comments

Comments
 (0)